uncrustify sources
This commit is contained in:
parent
ef090ed65d
commit
8fe8503cbd
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Common #includes and #defines. */
|
/* Common #includes and #defines. */
|
||||||
|
|
||||||
/* $Id: common.h,v 1.7 2001/10/27 23:20:24 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef COMMON_H
|
#ifndef COMMON_H
|
||||||
|
@ -98,7 +98,8 @@ uerr_t connect_to_server(int *sock, const char *name, int port,
|
|||||||
|
|
||||||
if (errno == EINPROGRESS)
|
if (errno == EINPROGRESS)
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
} else if (status == 0)
|
}
|
||||||
|
else if (status == 0)
|
||||||
errno = ETIMEDOUT, status = -1;
|
errno = ETIMEDOUT, status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,12 +111,14 @@ uerr_t connect_to_server(int *sock, const char *name, int port,
|
|||||||
{
|
{
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return CONREFUSED;
|
return CONREFUSED;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
freeaddrinfo(res);
|
freeaddrinfo(res);
|
||||||
return CONERROR;
|
return CONERROR;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
flags = fcntl(*sock, F_GETFL, 0);
|
flags = fcntl(*sock, F_GETFL, 0);
|
||||||
|
|
||||||
@ -209,8 +212,7 @@ int krecv(int sock, char *buffer, int size, int flags,
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = select_fd(sock, timeout, 0);
|
ret = select_fd(sock, timeout, 0);
|
||||||
}
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
while ((ret == -1) && (errno == EINTR));
|
|
||||||
|
|
||||||
|
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
@ -226,8 +228,7 @@ int krecv(int sock, char *buffer, int size, int flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = recv(sock, buffer, size, flags);
|
ret = recv(sock, buffer, size, flags);
|
||||||
}
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
while ((ret == -1) && (errno == EINTR));
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -254,8 +255,7 @@ int ksend(int sock, char *buffer, int size, int flags,
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = select_fd(sock, timeout, 1);
|
ret = select_fd(sock, timeout, 1);
|
||||||
}
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
while ((ret == -1) && (errno == EINTR));
|
|
||||||
|
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
{
|
{
|
||||||
@ -266,8 +266,7 @@ int ksend(int sock, char *buffer, int size, int flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = send(sock, buffer, size, flags);
|
ret = send(sock, buffer, size, flags);
|
||||||
}
|
} while ((ret == -1) && (errno == EINTR));
|
||||||
while ((ret == -1) && (errno == EINTR));
|
|
||||||
|
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
break;
|
break;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Connection routines. */
|
/* Connection routines. */
|
||||||
|
|
||||||
/* $Id: connect.h,v 1.17 2001/05/09 22:58:00 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef CONNECT_H
|
#ifndef CONNECT_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Several connection-related routines. */
|
/* Several connection-related routines. */
|
||||||
|
|
||||||
/* $Id: connection.c,v 1.48 2005/09/19 16:18:02 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -59,8 +59,7 @@ void done_with_response(connection_t * connection)
|
|||||||
p = p1;
|
p = p1;
|
||||||
p1 = p->next;
|
p1 = p->next;
|
||||||
kfree(p);
|
kfree(p);
|
||||||
}
|
} while (p1 != 0);
|
||||||
while (p1 != 0);
|
|
||||||
|
|
||||||
connection->serv_ret_lines = 0;
|
connection->serv_ret_lines = 0;
|
||||||
}
|
}
|
||||||
@ -71,8 +70,8 @@ void done_with_response(connection_t * connection)
|
|||||||
|
|
||||||
connection_t * proz_connection_init(urlinfo *url, pthread_mutex_t * mutex)
|
connection_t * proz_connection_init(urlinfo *url, pthread_mutex_t * mutex)
|
||||||
{
|
{
|
||||||
|
|
||||||
connection_t * connection = kmalloc(sizeof(connection_t));
|
connection_t * connection = kmalloc(sizeof(connection_t));
|
||||||
|
|
||||||
memset(connection, 0, sizeof(connection_t));
|
memset(connection, 0, sizeof(connection_t));
|
||||||
|
|
||||||
/* memcpy(&connection->u, url, sizeof(urlinfo));*/
|
/* memcpy(&connection->u, url, sizeof(urlinfo));*/
|
||||||
@ -191,8 +190,7 @@ uerr_t connection_retr_fsize_not_known(connection_t * connection,
|
|||||||
connection_calc_ratebps(connection);
|
connection_calc_ratebps(connection);
|
||||||
connection_throttle_bps(connection);
|
connection_throttle_bps(connection);
|
||||||
}
|
}
|
||||||
}
|
} while (bytes_read > 0);
|
||||||
while (bytes_read > 0);
|
|
||||||
|
|
||||||
if (bytes_read == -1)
|
if (bytes_read == -1)
|
||||||
{
|
{
|
||||||
@ -267,10 +265,8 @@ uerr_t connection_retr_fsize_known(connection_t * connection,
|
|||||||
|
|
||||||
if (bytes_read > 0)
|
if (bytes_read > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (write_data_with_lock(connection, read_buffer, sizeof(char), bytes_read) < bytes_read)
|
if (write_data_with_lock(connection, read_buffer, sizeof(char), bytes_read) < bytes_read)
|
||||||
{
|
{
|
||||||
|
|
||||||
proz_debug(_("write failed"));
|
proz_debug(_("write failed"));
|
||||||
connection_show_message(connection,
|
connection_show_message(connection,
|
||||||
_
|
_
|
||||||
@ -307,9 +303,6 @@ uerr_t connection_retr_fsize_known(connection_t * connection,
|
|||||||
|
|
||||||
int connection_load_resume_info(connection_t * connection)
|
int connection_load_resume_info(connection_t * connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (connection->remote_startpos - connection->orig_remote_startpos != connection->remote_bytes_received)
|
if (connection->remote_startpos - connection->orig_remote_startpos != connection->remote_bytes_received)
|
||||||
{
|
{
|
||||||
proz_debug("connection->remote start pos before loading %ld", connection->remote_startpos);
|
proz_debug("connection->remote start pos before loading %ld", connection->remote_startpos);
|
||||||
@ -324,6 +317,7 @@ int connection_load_resume_info(connection_t * connection)
|
|||||||
dl_status proz_connection_get_status(connection_t * connection)
|
dl_status proz_connection_get_status(connection_t * connection)
|
||||||
{
|
{
|
||||||
dl_status status;
|
dl_status status;
|
||||||
|
|
||||||
pthread_mutex_lock(connection->status_change_mutex);
|
pthread_mutex_lock(connection->status_change_mutex);
|
||||||
status = connection->status;
|
status = connection->status;
|
||||||
pthread_mutex_unlock(connection->status_change_mutex);
|
pthread_mutex_unlock(connection->status_change_mutex);
|
||||||
@ -335,13 +329,13 @@ dl_status proz_connection_get_status(connection_t * connection)
|
|||||||
char *proz_connection_get_status_string(connection_t * connection)
|
char *proz_connection_get_status_string(connection_t * connection)
|
||||||
{
|
{
|
||||||
dl_status status;
|
dl_status status;
|
||||||
|
|
||||||
pthread_mutex_lock(connection->status_change_mutex);
|
pthread_mutex_lock(connection->status_change_mutex);
|
||||||
status = connection->status;
|
status = connection->status;
|
||||||
pthread_mutex_unlock(connection->status_change_mutex);
|
pthread_mutex_unlock(connection->status_change_mutex);
|
||||||
|
|
||||||
switch (connection->status)
|
switch (connection->status)
|
||||||
{
|
{
|
||||||
|
|
||||||
case IDLE:
|
case IDLE:
|
||||||
return(_("Idle"));
|
return(_("Idle"));
|
||||||
|
|
||||||
@ -354,6 +348,7 @@ char *proz_connection_get_status_string(connection_t * connection)
|
|||||||
case DOWNLOADING:
|
case DOWNLOADING:
|
||||||
return(_("Downloading"));
|
return(_("Downloading"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COMPLETED:
|
case COMPLETED:
|
||||||
return(_("Completed"));
|
return(_("Completed"));
|
||||||
|
|
||||||
@ -371,6 +366,7 @@ char *proz_connection_get_status_string(connection_t * connection)
|
|||||||
|
|
||||||
case TIMEDOUT:
|
case TIMEDOUT:
|
||||||
return(_("Timed Out"));
|
return(_("Timed Out"));
|
||||||
|
|
||||||
case MAXTRYS:
|
case MAXTRYS:
|
||||||
return(_("Max attempts reached"));
|
return(_("Max attempts reached"));
|
||||||
|
|
||||||
@ -412,7 +408,6 @@ off_t proz_connection_get_total_bytes_got(connection_t * connection)
|
|||||||
pthread_mutex_unlock(&connection->access_mutex);
|
pthread_mutex_unlock(&connection->access_mutex);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
@ -422,6 +417,7 @@ by this connection.
|
|||||||
off_t proz_connection_get_total_remote_bytes_got(connection_t * connection)
|
off_t proz_connection_get_total_remote_bytes_got(connection_t * connection)
|
||||||
{
|
{
|
||||||
off_t ret;
|
off_t ret;
|
||||||
|
|
||||||
pthread_mutex_lock(&connection->access_mutex);
|
pthread_mutex_lock(&connection->access_mutex);
|
||||||
ret = (connection->remote_bytes_received
|
ret = (connection->remote_bytes_received
|
||||||
- (connection->remote_startpos - connection->orig_remote_startpos));
|
- (connection->remote_startpos - connection->orig_remote_startpos));
|
||||||
@ -447,7 +443,6 @@ handling conditions like redirection from http to ftp etc
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
void get_url_info_loop(connection_t * connection)
|
void get_url_info_loop(connection_t * connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
|
||||||
|
|
||||||
/*TODO Should we try to make it broadcast a condition to the other threads? */
|
/*TODO Should we try to make it broadcast a condition to the other threads? */
|
||||||
@ -462,9 +457,11 @@ void get_url_info_loop(connection_t * connection)
|
|||||||
case URLHTTP:
|
case URLHTTP:
|
||||||
connection->err = http_get_url_info_loop(connection);
|
connection->err = http_get_url_info_loop(connection);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case URLFTP:
|
case URLFTP:
|
||||||
connection->err = ftp_get_url_info_loop(connection);
|
connection->err = ftp_get_url_info_loop(connection);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
proz_die(_("Error: unsupported protocol"));
|
proz_die(_("Error: unsupported protocol"));
|
||||||
}
|
}
|
||||||
@ -498,16 +495,15 @@ void get_url_info_loop(connection_t * connection)
|
|||||||
kfree(constructed_newloc);
|
kfree(constructed_newloc);
|
||||||
connection->err = HERR;
|
connection->err = HERR;
|
||||||
return;
|
return;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
connection_show_message(connection, _("Redirected to => %s"),
|
connection_show_message(connection, _("Redirected to => %s"),
|
||||||
constructed_newloc);
|
constructed_newloc);
|
||||||
connection->u.referer = referer;
|
connection->u.referer = referer;
|
||||||
kfree(constructed_newloc);
|
kfree(constructed_newloc);
|
||||||
connection->err = NEWLOCATION;
|
connection->err = NEWLOCATION;
|
||||||
}
|
}
|
||||||
|
} while (connection->err == NEWLOCATION);
|
||||||
}
|
|
||||||
while (connection->err == NEWLOCATION);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -536,11 +532,11 @@ void connection_calc_ratebps(connection_t * connection)
|
|||||||
if (connection->time_begin.tv_sec == 0
|
if (connection->time_begin.tv_sec == 0
|
||||||
&& connection->time_begin.tv_usec == 0)
|
&& connection->time_begin.tv_usec == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
connection->rate_bps = 0;
|
connection->rate_bps = 0;
|
||||||
pthread_mutex_unlock(&connection->access_mutex);
|
pthread_mutex_unlock(&connection->access_mutex);
|
||||||
return;
|
return;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
gettimeofday(&tv_cur, NULL);
|
gettimeofday(&tv_cur, NULL);
|
||||||
proz_timeval_subtract(&tv_diff, &tv_cur, &(connection->time_begin));
|
proz_timeval_subtract(&tv_diff, &tv_cur, &(connection->time_begin));
|
||||||
@ -575,7 +571,6 @@ void connection_calc_ratebps(connection_t * connection)
|
|||||||
|
|
||||||
void connection_throttle_bps(connection_t * connection)
|
void connection_throttle_bps(connection_t * connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct timeval tv_cur;
|
struct timeval tv_cur;
|
||||||
struct timeval tv_diff;
|
struct timeval tv_diff;
|
||||||
float diff_us;
|
float diff_us;
|
||||||
@ -651,7 +646,8 @@ void connection_throttle_bps(connection_t * connection)
|
|||||||
("Cant throttle fully : Connection would timeout if done so, please try increasing the timeout value"); */
|
("Cant throttle fully : Connection would timeout if done so, please try increasing the timeout value"); */
|
||||||
|
|
||||||
proz_debug("delaymaxlimit %ld sec\n", tv_delay.tv_usec);
|
proz_debug("delaymaxlimit %ld sec\n", tv_delay.tv_usec);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
tv_delay.tv_usec = (wtime - diff_us);
|
tv_delay.tv_usec = (wtime - diff_us);
|
||||||
//#warning "comment out the following line before releasing the code base"
|
//#warning "comment out the following line before releasing the code base"
|
||||||
@ -665,7 +661,6 @@ void connection_throttle_bps(connection_t * connection)
|
|||||||
{
|
{
|
||||||
proz_debug("Unable to throttle Bandwith\n");
|
proz_debug("Unable to throttle Bandwith\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,6 +668,7 @@ void connection_throttle_bps(connection_t * connection)
|
|||||||
boolean proz_connection_running(connection_t * connection)
|
boolean proz_connection_running(connection_t * connection)
|
||||||
{
|
{
|
||||||
boolean running;
|
boolean running;
|
||||||
|
|
||||||
pthread_mutex_lock(&connection->access_mutex);
|
pthread_mutex_lock(&connection->access_mutex);
|
||||||
running = connection->running;
|
running = connection->running;
|
||||||
pthread_mutex_unlock(&connection->access_mutex);
|
pthread_mutex_unlock(&connection->access_mutex);
|
||||||
@ -719,6 +715,7 @@ void proz_connection_free_connection(connection_t * connection,
|
|||||||
size_t write_data_with_lock(connection_t * connection, const void *ptr, size_t size, size_t nmemb)
|
size_t write_data_with_lock(connection_t * connection, const void *ptr, size_t size, size_t nmemb)
|
||||||
{
|
{
|
||||||
size_t ret;
|
size_t ret;
|
||||||
|
|
||||||
flockfile(connection->fp);
|
flockfile(connection->fp);
|
||||||
/*Seek appropriately......*/
|
/*Seek appropriately......*/
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Several connection-related routines. */
|
/* Several connection-related routines. */
|
||||||
|
|
||||||
/* $Id: connection.h,v 1.34 2005/01/11 01:49:11 sean Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef CONNECTION_H
|
#ifndef CONNECTION_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Debugging routines. */
|
/* Debugging routines. */
|
||||||
|
|
||||||
/* $Id: debug.c,v 1.20 2001/08/17 21:53:39 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -43,8 +43,8 @@ void debug_init()
|
|||||||
|
|
||||||
void proz_debug_delete_log()
|
void proz_debug_delete_log()
|
||||||
{
|
{
|
||||||
|
|
||||||
char logfile_name[PATH_MAX];
|
char logfile_name[PATH_MAX];
|
||||||
|
|
||||||
snprintf(logfile_name, PATH_MAX, "%s/debug.log", libprozrtinfo.log_dir);
|
snprintf(logfile_name, PATH_MAX, "%s/debug.log", libprozrtinfo.log_dir);
|
||||||
|
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ void proz_debug(const char *format, ...)
|
|||||||
char message[MAX_MSG_SIZE + 1 + 1];
|
char message[MAX_MSG_SIZE + 1 + 1];
|
||||||
|
|
||||||
char logfile_name[PATH_MAX];
|
char logfile_name[PATH_MAX];
|
||||||
|
|
||||||
snprintf(logfile_name, PATH_MAX, "%s/debug.log", libprozrtinfo.log_dir);
|
snprintf(logfile_name, PATH_MAX, "%s/debug.log", libprozrtinfo.log_dir);
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Debugging routines. */
|
/* Debugging routines. */
|
||||||
|
|
||||||
/* $Id: debug.h,v 1.14 2001/07/11 23:19:41 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef DEBUG_H
|
#ifndef DEBUG_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Download routines. */
|
/* Download routines. */
|
||||||
|
|
||||||
/* $Id: download.c,v 1.42 2005/09/19 16:18:02 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -36,7 +36,6 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
download_t *proz_download_init(urlinfo * u)
|
download_t *proz_download_init(urlinfo * u)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* pthread_mutexattr_t attr; */
|
/* pthread_mutexattr_t attr; */
|
||||||
download_t *download = kmalloc(sizeof(download_t));
|
download_t *download = kmalloc(sizeof(download_t));
|
||||||
|
|
||||||
@ -90,8 +89,8 @@ int proz_download_setup_connections_no_ftpsearch(download_t * download,
|
|||||||
num_connections = 1;
|
num_connections = 1;
|
||||||
bytes_per_connection = -1;
|
bytes_per_connection = -1;
|
||||||
bytes_left = -1;
|
bytes_left = -1;
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
if (connection->resume_support == FALSE)
|
if (connection->resume_support == FALSE)
|
||||||
num_connections = 1;
|
num_connections = 1;
|
||||||
@ -137,7 +136,6 @@ int proz_download_setup_connections_no_ftpsearch(download_t * download,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
proz_debug("created file");
|
proz_debug("created file");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -161,14 +159,12 @@ int proz_download_setup_connections_no_ftpsearch(download_t * download,
|
|||||||
out_file, strerror(errno));
|
out_file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TRY setting the offset;
|
//TRY setting the offset;
|
||||||
if (download->main_file_size != -1)
|
if (download->main_file_size != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fseeko(fp, download->main_file_size, SEEK_SET) != 0)
|
if (fseeko(fp, download->main_file_size, SEEK_SET) != 0)
|
||||||
{
|
{
|
||||||
proz_debug("fseek failed");
|
proz_debug("fseek failed");
|
||||||
@ -208,7 +204,8 @@ int proz_download_setup_connections_no_ftpsearch(download_t * download,
|
|||||||
|
|
||||||
|
|
||||||
download->pconnections[i]->local_startpos = 0;
|
download->pconnections[i]->local_startpos = 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
download->pconnections[i]->main_file_size = connection->main_file_size;
|
download->pconnections[i]->main_file_size = connection->main_file_size;
|
||||||
download->pconnections[i]->orig_remote_startpos = download->pconnections[i]->remote_startpos = i * bytes_per_connection;
|
download->pconnections[i]->orig_remote_startpos = download->pconnections[i]->remote_startpos = i * bytes_per_connection;
|
||||||
@ -248,16 +245,15 @@ int proz_download_load_resume_info(download_t * download)
|
|||||||
int i;
|
int i;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
logfile lf;
|
logfile lf;
|
||||||
|
|
||||||
if (proz_log_read_logfile(&lf, download, TRUE) == 1)
|
if (proz_log_read_logfile(&lf, download, TRUE) == 1)
|
||||||
proz_debug("sucessfully loaded resume info");
|
proz_debug("sucessfully loaded resume info");
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (download->pconnections[i]->remote_endpos - download->pconnections[i]->remote_startpos == download->pconnections[i]->remote_bytes_received)
|
if (download->pconnections[i]->remote_endpos - download->pconnections[i]->remote_startpos == download->pconnections[i]->remote_bytes_received)
|
||||||
{
|
{
|
||||||
|
|
||||||
connection_change_status(download->pconnections[i], COMPLETED);
|
connection_change_status(download->pconnections[i], COMPLETED);
|
||||||
//This should fix the error we received when resuming when the
|
//This should fix the error we received when resuming when the
|
||||||
//average rate was too high.
|
//average rate was too high.
|
||||||
@ -266,8 +262,6 @@ int proz_download_load_resume_info(download_t * download)
|
|||||||
}
|
}
|
||||||
|
|
||||||
download->pconnections[i]->remote_startpos += download->pconnections[i]->remote_bytes_received;
|
download->pconnections[i]->remote_startpos += download->pconnections[i]->remote_bytes_received;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
download->resume_mode = TRUE;
|
download->resume_mode = TRUE;
|
||||||
@ -281,7 +275,6 @@ int proz_download_load_resume_info(download_t * download)
|
|||||||
void proz_download_start_downloads(download_t * download,
|
void proz_download_start_downloads(download_t * download,
|
||||||
boolean resume_mode)
|
boolean resume_mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (resume_mode)
|
if (resume_mode)
|
||||||
@ -320,6 +313,7 @@ else
|
|||||||
proz_die(_("Error: Not enough system resources"));
|
proz_die(_("Error: Not enough system resources"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case URLFTP:
|
case URLFTP:
|
||||||
|
|
||||||
/* ftp_loop(&download->connections[i]); */
|
/* ftp_loop(&download->connections[i]); */
|
||||||
@ -331,6 +325,7 @@ else
|
|||||||
proz_die(_("Error: Not enough system resources"));
|
proz_die(_("Error: Not enough system resources"));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
proz_die(_("Error: Unsupported Protocol was specified"));
|
proz_die(_("Error: Unsupported Protocol was specified"));
|
||||||
}
|
}
|
||||||
@ -342,6 +337,7 @@ else
|
|||||||
void proz_download_stop_downloads(download_t * download)
|
void proz_download_stop_downloads(download_t * download)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*Stop the threads */
|
/*Stop the threads */
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
@ -354,8 +350,6 @@ void proz_download_stop_downloads(download_t * download)
|
|||||||
/* returns one of DLINPROGRESS, DLERR, DLDONE, DLREMOTEFATAL, DLLOCALFATAL*/
|
/* returns one of DLINPROGRESS, DLERR, DLDONE, DLREMOTEFATAL, DLLOCALFATAL*/
|
||||||
uerr_t proz_download_handle_threads(download_t * download)
|
uerr_t proz_download_handle_threads(download_t * download)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//Create logfile everytime this is callaed
|
//Create logfile everytime this is callaed
|
||||||
log_create_logfile(download->num_connections, download->main_file_size, download->u.url, download);
|
log_create_logfile(download->num_connections, download->main_file_size, download->u.url, download);
|
||||||
|
|
||||||
@ -449,7 +443,8 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
/*FIXME Do we delete any downloaded portions here ? */
|
/*FIXME Do we delete any downloaded portions here ? */
|
||||||
return CANTRESUME;
|
return CANTRESUME;
|
||||||
} else /*Handle the file not being found on the server */
|
}
|
||||||
|
else /*Handle the file not being found on the server */
|
||||||
if (connection_err == FTPNSFOD || connection_err == HTTPNSFOD)
|
if (connection_err == FTPNSFOD || connection_err == HTTPNSFOD)
|
||||||
{
|
{
|
||||||
if (proz_download_all_dls_filensfod(download) == TRUE)
|
if (proz_download_all_dls_filensfod(download) == TRUE)
|
||||||
@ -460,7 +455,8 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
/*Terminate the connections */
|
/*Terminate the connections */
|
||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
return DLREMOTEFATAL;
|
return DLREMOTEFATAL;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
download_show_message(download, _("Relaunching download"));
|
download_show_message(download, _("Relaunching download"));
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
@ -475,7 +471,8 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
}
|
}
|
||||||
} else /*Handle the file not being found on the server */
|
}
|
||||||
|
else /*Handle the file not being found on the server */
|
||||||
if (connection_err == FTPCWDFAIL)
|
if (connection_err == FTPCWDFAIL)
|
||||||
{
|
{
|
||||||
if (proz_download_all_dls_ftpcwdfail(download) == TRUE)
|
if (proz_download_all_dls_ftpcwdfail(download) == TRUE)
|
||||||
@ -486,7 +483,8 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
/*Terminate the connections */
|
/*Terminate the connections */
|
||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
return DLREMOTEFATAL;
|
return DLREMOTEFATAL;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
download_show_message(download, _("Relaunching download"));
|
download_show_message(download, _("Relaunching download"));
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
@ -536,9 +534,9 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
break;
|
break;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ok so at least there is one download whos login has not been rejected,
|
* Ok so at least there is one download whos login has not been rejected,
|
||||||
* so lets see if it has completed, if so we can relaunch this connection,
|
* so lets see if it has completed, if so we can relaunch this connection,
|
||||||
@ -568,28 +566,6 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&& (download_query_conns_status_count(download, LOGGININ, NULL)
|
&& (download_query_conns_status_count(download, LOGGININ, NULL)
|
||||||
== 0))
|
== 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
|
||||||
pthread_join(download->threads[i], NULL);
|
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
|
||||||
download_show_message(download, _("Relaunching download"));
|
|
||||||
if (pthread_create(&download->threads[i], NULL,
|
|
||||||
(void *) &ftp_loop,
|
|
||||||
(void *) (download->pconnections[i])) != 0)
|
|
||||||
proz_die(_("Error: Not enough system resources"));
|
|
||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
|
||||||
&download->status_change_mutex);
|
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
|
||||||
} else
|
|
||||||
if (dling_conns_count < download->max_simul_connections
|
|
||||||
&&
|
|
||||||
(download_query_conns_status_count
|
|
||||||
(download, CONNECTING, NULL) == 0)
|
|
||||||
&&
|
|
||||||
(download_query_conns_status_count
|
|
||||||
(download, LOGGININ, NULL) == 0))
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
pthread_join(download->threads[i], NULL);
|
pthread_join(download->threads[i], NULL);
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
@ -602,7 +578,27 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (dling_conns_count < download->max_simul_connections
|
||||||
|
&&
|
||||||
|
(download_query_conns_status_count
|
||||||
|
(download, CONNECTING, NULL) == 0)
|
||||||
|
&&
|
||||||
|
(download_query_conns_status_count
|
||||||
|
(download, LOGGININ, NULL) == 0))
|
||||||
|
{
|
||||||
|
/* Make sure this thread has terminated */
|
||||||
|
pthread_join(download->threads[i], NULL);
|
||||||
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
|
download_show_message(download, _("Relaunching download"));
|
||||||
|
if (pthread_create(&download->threads[i], NULL,
|
||||||
|
(void *)&ftp_loop,
|
||||||
|
(void *)(download->pconnections[i])) != 0)
|
||||||
|
proz_die(_("Error: Not enough system resources"));
|
||||||
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
|
&download->status_change_mutex);
|
||||||
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -629,7 +625,8 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
break;
|
break;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Ok so at least there is one download whos connections attempt has not been rejected,
|
* Ok so at least there is one download whos connections attempt has not been rejected,
|
||||||
@ -660,28 +657,6 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&& (download_query_conns_status_count(download, LOGGININ, NULL)
|
&& (download_query_conns_status_count(download, LOGGININ, NULL)
|
||||||
== 0))
|
== 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
|
||||||
pthread_join(download->threads[i], NULL);
|
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
|
||||||
download_show_message(download, _("Relaunching download"));
|
|
||||||
if (pthread_create(&download->threads[i], NULL,
|
|
||||||
(void *) &ftp_loop,
|
|
||||||
(void *) (download->pconnections[i])) != 0)
|
|
||||||
proz_die(_("Error: Not enough system resources"));
|
|
||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
|
||||||
&download->status_change_mutex);
|
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
|
||||||
} else
|
|
||||||
if (dling_conns_count < download->max_simul_connections
|
|
||||||
&&
|
|
||||||
(download_query_conns_status_count
|
|
||||||
(download, CONNECTING, NULL) == 0)
|
|
||||||
&&
|
|
||||||
(download_query_conns_status_count
|
|
||||||
(download, LOGGININ, NULL) == 0))
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
pthread_join(download->threads[i], NULL);
|
pthread_join(download->threads[i], NULL);
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
@ -694,7 +669,27 @@ uerr_t download_handle_threads_no_ftpsearch(download_t * download)
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (dling_conns_count < download->max_simul_connections
|
||||||
|
&&
|
||||||
|
(download_query_conns_status_count
|
||||||
|
(download, CONNECTING, NULL) == 0)
|
||||||
|
&&
|
||||||
|
(download_query_conns_status_count
|
||||||
|
(download, LOGGININ, NULL) == 0))
|
||||||
|
{
|
||||||
|
/* Make sure this thread has terminated */
|
||||||
|
pthread_join(download->threads[i], NULL);
|
||||||
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
|
download_show_message(download, _("Relaunching download"));
|
||||||
|
if (pthread_create(&download->threads[i], NULL,
|
||||||
|
(void *)&ftp_loop,
|
||||||
|
(void *)(download->pconnections[i])) != 0)
|
||||||
|
proz_die(_("Error: Not enough system resources"));
|
||||||
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
|
&download->status_change_mutex);
|
||||||
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -737,7 +732,6 @@ connection_t *proz_download_get_connection(download_t * download,
|
|||||||
{
|
{
|
||||||
assert(number >= 0 && number < download->num_connections);
|
assert(number >= 0 && number < download->num_connections);
|
||||||
return(download->pconnections[number]);
|
return(download->pconnections[number]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -790,13 +784,14 @@ float proz_download_get_average_speed(download_t * download)
|
|||||||
speed = (float)total_remote_bytes_got / ((float)diff_time.tv_sec +
|
speed = (float)total_remote_bytes_got / ((float)diff_time.tv_sec +
|
||||||
((float)diff_time.
|
((float)diff_time.
|
||||||
tv_usec / 10e5));
|
tv_usec / 10e5));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
speed = 0;
|
speed = 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
speed = 0; /*The DL hasnt started yet */
|
speed = 0; /*The DL hasnt started yet */
|
||||||
|
|
||||||
return speed;
|
return speed;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -806,6 +801,7 @@ float proz_download_get_average_speed(download_t * download)
|
|||||||
int proz_download_delete_dl_file(download_t * download)
|
int proz_download_delete_dl_file(download_t * download)
|
||||||
{
|
{
|
||||||
char *out_file;
|
char *out_file;
|
||||||
|
|
||||||
out_file = kmalloc(PATH_MAX);
|
out_file = kmalloc(PATH_MAX);
|
||||||
snprintf(out_file, PATH_MAX, "%s/%s.prozilla",
|
snprintf(out_file, PATH_MAX, "%s/%s.prozilla",
|
||||||
download->dl_dir, download->u.file);
|
download->dl_dir, download->u.file);
|
||||||
@ -838,6 +834,7 @@ int proz_download_delete_dl_file(download_t * download)
|
|||||||
void proz_download_wait_till_all_end(download_t * download)
|
void proz_download_wait_till_all_end(download_t * download)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/*Wait till the end of all the threads */
|
/*Wait till the end of all the threads */
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
@ -868,7 +865,6 @@ void download_join_downloads(download_t * download)
|
|||||||
/*This function will join the downloaded files*/
|
/*This function will join the downloaded files*/
|
||||||
void join_downloads(download_t * download)
|
void join_downloads(download_t * download)
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_mutex_lock(&download->access_mutex);
|
pthread_mutex_lock(&download->access_mutex);
|
||||||
download->building = 0;
|
download->building = 0;
|
||||||
pthread_mutex_unlock(&download->access_mutex);
|
pthread_mutex_unlock(&download->access_mutex);
|
||||||
@ -883,7 +879,6 @@ by the all the connections managed by this download
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
off_t proz_download_get_total_remote_bytes_got(download_t * download)
|
off_t proz_download_get_total_remote_bytes_got(download_t * download)
|
||||||
{
|
{
|
||||||
|
|
||||||
off_t total_bytes_recv = 0;
|
off_t total_bytes_recv = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -903,6 +898,7 @@ off_t proz_download_get_total_remote_bytes_got(download_t * download)
|
|||||||
int proz_download_all_dls_status(download_t * download, dl_status status)
|
int proz_download_all_dls_status(download_t * download, dl_status status)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
{
|
{
|
||||||
@ -924,6 +920,7 @@ boolean proz_download_all_dls_filensfod(download_t * download)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
|
|
||||||
/*Lock mutex */
|
/*Lock mutex */
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
@ -946,6 +943,7 @@ boolean proz_download_all_dls_ftpcwdfail(download_t * download)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
|
|
||||||
/*Lock mutex */
|
/*Lock mutex */
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
@ -970,6 +968,7 @@ boolean proz_download_all_dls_err(download_t * download, uerr_t in_err)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
|
|
||||||
/*Lock mutex */
|
/*Lock mutex */
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
@ -993,6 +992,7 @@ int download_query_conns_status_count(download_t * download,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
|
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
@ -1027,7 +1027,6 @@ if it cannot be calculated say if the file size of not known, it returns -1
|
|||||||
*/
|
*/
|
||||||
off_t proz_download_get_est_time_left(download_t * download)
|
off_t proz_download_get_est_time_left(download_t * download)
|
||||||
{
|
{
|
||||||
|
|
||||||
long secs_left;
|
long secs_left;
|
||||||
float average_speed;
|
float average_speed;
|
||||||
off_t total_bytes_got;
|
off_t total_bytes_got;
|
||||||
@ -1044,13 +1043,11 @@ off_t proz_download_get_est_time_left(download_t * download)
|
|||||||
return secs_left =
|
return secs_left =
|
||||||
(off_t)((download->main_file_size -
|
(off_t)((download->main_file_size -
|
||||||
total_bytes_got) / average_speed);
|
total_bytes_got) / average_speed);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void proz_download_free_download(download_t * download, boolean complete)
|
void proz_download_free_download(download_t * download, boolean complete)
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(download);
|
assert(download);
|
||||||
/*TODO free the URL */
|
/*TODO free the URL */
|
||||||
|
|
||||||
@ -1177,7 +1174,6 @@ Returns,
|
|||||||
|
|
||||||
int proz_download_target_exist(download_t * download)
|
int proz_download_target_exist(download_t * download)
|
||||||
{
|
{
|
||||||
|
|
||||||
char out_file_name[PATH_MAX];
|
char out_file_name[PATH_MAX];
|
||||||
struct stat st_buf;
|
struct stat st_buf;
|
||||||
int ret;
|
int ret;
|
||||||
@ -1196,7 +1192,6 @@ int proz_download_target_exist(download_t * download)
|
|||||||
|
|
||||||
/*File was statable so it exists */
|
/*File was statable so it exists */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1209,7 +1204,6 @@ Returns,
|
|||||||
|
|
||||||
int proz_download_delete_target(download_t * download)
|
int proz_download_delete_target(download_t * download)
|
||||||
{
|
{
|
||||||
|
|
||||||
char out_file_name[PATH_MAX];
|
char out_file_name[PATH_MAX];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1227,7 +1221,6 @@ int proz_download_delete_target(download_t * download)
|
|||||||
|
|
||||||
/*File was statable so it exists */
|
/*File was statable so it exists */
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Tries to switch to another server which is downloading or has completed, returns 1 on sucesss, or -1 on failure
|
/*Tries to switch to another server which is downloading or has completed, returns 1 on sucesss, or -1 on failure
|
||||||
@ -1277,13 +1270,12 @@ int download_switch_server_ftpsearch(download_t *download, int bad_connection)
|
|||||||
pthread_cond_wait(&download->pconnections[bad_connection]->connecting_cond, &download->status_change_mutex);
|
pthread_cond_wait(&download->pconnections[bad_connection]->connecting_cond, &download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
/*Shit! no servers are downloading or completed so what shall we do? we shall do nothing and wait for one connectection at least to start downloading */
|
/*Shit! no servers are downloading or completed so what shall we do? we shall do nothing and wait for one connectection at least to start downloading */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns one of DLINPROGRESS, DLERR, DLDONE, DLREMOTEFATAL, DLLOCALFATAL*/
|
/* returns one of DLINPROGRESS, DLERR, DLDONE, DLREMOTEFATAL, DLLOCALFATAL*/
|
||||||
@ -1368,7 +1360,8 @@ uerr_t download_handle_threads_ftpsearch(download_t * download)
|
|||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
/*FIXME Do we delete any downloaded portions here ? */
|
/*FIXME Do we delete any downloaded portions here ? */
|
||||||
return CANTRESUME;
|
return CANTRESUME;
|
||||||
} else /*Handle the file not being found on the server */
|
}
|
||||||
|
else /*Handle the file not being found on the server */
|
||||||
if (connection_err == FTPNSFOD || connection_err == HTTPNSFOD)
|
if (connection_err == FTPNSFOD || connection_err == HTTPNSFOD)
|
||||||
{
|
{
|
||||||
if (proz_download_all_dls_filensfod(download) == TRUE)
|
if (proz_download_all_dls_filensfod(download) == TRUE)
|
||||||
@ -1379,9 +1372,9 @@ uerr_t download_handle_threads_ftpsearch(download_t * download)
|
|||||||
/*Terminate the connections */
|
/*Terminate the connections */
|
||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
return DLREMOTEFATAL;
|
return DLREMOTEFATAL;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Now we have to be careful */
|
/*Now we have to be careful */
|
||||||
int server_pos, cur_path_pos;
|
int server_pos, cur_path_pos;
|
||||||
|
|
||||||
@ -1449,9 +1442,9 @@ uerr_t download_handle_threads_ftpsearch(download_t * download)
|
|||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/*download_show_message(download,
|
/*download_show_message(download,
|
||||||
_
|
_
|
||||||
("No additional paths on this server available, so will try to switch to another server")); */
|
("No additional paths on this server available, so will try to switch to another server")); */
|
||||||
@ -1459,7 +1452,8 @@ uerr_t download_handle_threads_ftpsearch(download_t * download)
|
|||||||
download_switch_server_ftpsearch(download, i);
|
download_switch_server_ftpsearch(download, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else /*Handle the file not being found on the server */
|
}
|
||||||
|
else /*Handle the file not being found on the server */
|
||||||
if (connection_err == FTPCWDFAIL)
|
if (connection_err == FTPCWDFAIL)
|
||||||
{
|
{
|
||||||
if (proz_download_all_dls_ftpcwdfail(download) == TRUE)
|
if (proz_download_all_dls_ftpcwdfail(download) == TRUE)
|
||||||
@ -1470,9 +1464,9 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
/*Terminate the connections */
|
/*Terminate the connections */
|
||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
return DLREMOTEFATAL;
|
return DLREMOTEFATAL;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Now we have to be careful */
|
/*Now we have to be careful */
|
||||||
int server_pos, cur_path_pos;
|
int server_pos, cur_path_pos;
|
||||||
|
|
||||||
@ -1534,9 +1528,9 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
(&download->threads[i], NULL, (void *)&ftp_loop,
|
(&download->threads[i], NULL, (void *)&ftp_loop,
|
||||||
(void *)(download->pconnections[i])) != 0)
|
(void *)(download->pconnections[i])) != 0)
|
||||||
proz_die(_("Error: Not enough system resources"));
|
proz_die(_("Error: Not enough system resources"));
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/* download_show_message(download, _("No additional paths on this server available, so will try to switch to another server")); */
|
/* download_show_message(download, _("No additional paths on this server available, so will try to switch to another server")); */
|
||||||
|
|
||||||
|
|
||||||
@ -1546,7 +1540,8 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
download_switch_server_ftpsearch(download, i);
|
download_switch_server_ftpsearch(download, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (connection_err == FTPRESTFAIL)
|
}
|
||||||
|
else if (connection_err == FTPRESTFAIL)
|
||||||
{
|
{
|
||||||
/*Handle the server not supporting REST */
|
/*Handle the server not supporting REST */
|
||||||
if (proz_download_all_dls_err(download, FTPRESTFAIL) == TRUE)
|
if (proz_download_all_dls_err(download, FTPRESTFAIL) == TRUE)
|
||||||
@ -1557,9 +1552,9 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
/*Terminate the connections */
|
/*Terminate the connections */
|
||||||
proz_download_stop_downloads(download);
|
proz_download_stop_downloads(download);
|
||||||
return DLREMOTEFATAL;
|
return DLREMOTEFATAL;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/*Now we have to be careful */
|
/*Now we have to be careful */
|
||||||
int server_pos;
|
int server_pos;
|
||||||
|
|
||||||
@ -1578,7 +1573,6 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
_
|
_
|
||||||
("This server does not support resuming downloads, so will switch to another server"));
|
("This server does not support resuming downloads, so will switch to another server"));
|
||||||
download_switch_server_ftpsearch(download, i);
|
download_switch_server_ftpsearch(download, i);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1617,9 +1611,9 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
break;
|
break;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
int j, usable_server;
|
int j, usable_server;
|
||||||
|
|
||||||
/*Find any server that is downloading or completed and use it instead */
|
/*Find any server that is downloading or completed and use it instead */
|
||||||
@ -1669,9 +1663,9 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ok so at least there is one download whos login has not been rejected,
|
* Ok so at least there is one download whos login has not been rejected,
|
||||||
* so lets see if it has completed, if so we can relaunch this connection,
|
* so lets see if it has completed, if so we can relaunch this connection,
|
||||||
@ -1711,7 +1705,6 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
(download_query_conns_status_count
|
(download_query_conns_status_count
|
||||||
(download, LOGGININ, download->pconnections[i]->u.host) == 0))
|
(download, LOGGININ, download->pconnections[i]->u.host) == 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
pthread_join(download->threads[i], NULL);
|
pthread_join(download->threads[i], NULL);
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
@ -1723,7 +1716,8 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
if (dling_conns_count <
|
if (dling_conns_count <
|
||||||
download->ftps_info->mirrors[server_pos].
|
download->ftps_info->mirrors[server_pos].
|
||||||
max_simul_connections
|
max_simul_connections
|
||||||
@ -1736,7 +1730,6 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
(download, LOGGININ,
|
(download, LOGGININ,
|
||||||
download->pconnections[i]->u.host) == 0))
|
download->pconnections[i]->u.host) == 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
pthread_join(download->threads[i], NULL);
|
pthread_join(download->threads[i], NULL);
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
@ -1775,9 +1768,9 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
break;
|
break;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
int j, usable_server;
|
int j, usable_server;
|
||||||
|
|
||||||
/*Find any server that is downloading or completed and use it instead */
|
/*Find any server that is downloading or completed and use it instead */
|
||||||
@ -1825,8 +1818,8 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Ok so at least there is one download whos connections attempt has not been rejected,
|
* Ok so at least there is one download whos connections attempt has not been rejected,
|
||||||
@ -1867,7 +1860,6 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
(download_query_conns_status_count
|
(download_query_conns_status_count
|
||||||
(download, LOGGININ, download->pconnections[i]->u.host) == 0))
|
(download, LOGGININ, download->pconnections[i]->u.host) == 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
pthread_join(download->threads[i], NULL);
|
pthread_join(download->threads[i], NULL);
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
@ -1879,7 +1871,8 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
pthread_cond_wait(&download->pconnections[i]->connecting_cond,
|
||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
pthread_mutex_unlock(&download->status_change_mutex);
|
pthread_mutex_unlock(&download->status_change_mutex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
if (dling_conns_count <
|
if (dling_conns_count <
|
||||||
download->ftps_info->mirrors[server_pos].
|
download->ftps_info->mirrors[server_pos].
|
||||||
max_simul_connections
|
max_simul_connections
|
||||||
@ -1892,7 +1885,6 @@ download_switch_server_ftpsearch(download, i);
|
|||||||
(download, LOGGININ,
|
(download, LOGGININ,
|
||||||
download->pconnections[i]->u.host) == 0))
|
download->pconnections[i]->u.host) == 0))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Make sure this thread has terminated */
|
/* Make sure this thread has terminated */
|
||||||
pthread_join(download->threads[i], NULL);
|
pthread_join(download->threads[i], NULL);
|
||||||
pthread_mutex_lock(&download->status_change_mutex);
|
pthread_mutex_lock(&download->status_change_mutex);
|
||||||
@ -1935,6 +1927,7 @@ int proz_download_setup_connections_ftpsearch(download_t * download,
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *out_file;
|
char *out_file;
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
|
|
||||||
/*TODO Check for log file and use same number of threads */
|
/*TODO Check for log file and use same number of threads */
|
||||||
|
|
||||||
proz_debug("proz_download_setup_connections_ftpsearch");
|
proz_debug("proz_download_setup_connections_ftpsearch");
|
||||||
@ -1993,8 +1986,8 @@ int proz_download_setup_connections_ftpsearch(download_t * download,
|
|||||||
|
|
||||||
download->pconnections[i] = proz_connection_init(url,
|
download->pconnections[i] = proz_connection_init(url,
|
||||||
&download->status_change_mutex);
|
&download->status_change_mutex);
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
int extra_mirror = 0;
|
int extra_mirror = 0;
|
||||||
/*FIXME improve allocation algorithm in this part */
|
/*FIXME improve allocation algorithm in this part */
|
||||||
@ -2051,7 +2044,6 @@ int proz_download_setup_connections_ftpsearch(download_t * download,
|
|||||||
out_file, strerror(errno));
|
out_file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
@ -2069,14 +2061,12 @@ int proz_download_setup_connections_ftpsearch(download_t * download,
|
|||||||
out_file, strerror(errno));
|
out_file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TRY setting the offset;
|
//TRY setting the offset;
|
||||||
if (download->main_file_size != -1)
|
if (download->main_file_size != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fseeko(fp, download->main_file_size, SEEK_SET) != 0)
|
if (fseeko(fp, download->main_file_size, SEEK_SET) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2109,7 +2099,8 @@ int proz_download_setup_connections_ftpsearch(download_t * download,
|
|||||||
|
|
||||||
/* Add the remaining bytes to the last connection */
|
/* Add the remaining bytes to the last connection */
|
||||||
download->pconnections[--i]->remote_endpos += bytes_left;
|
download->pconnections[--i]->remote_endpos += bytes_left;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
proz_debug("No mirrors, which were up are found");
|
proz_debug("No mirrors, which were up are found");
|
||||||
download->using_ftpsearch = FALSE;
|
download->using_ftpsearch = FALSE;
|
||||||
@ -2125,8 +2116,8 @@ int proz_download_setup_connections_ftpsearch(download_t * download,
|
|||||||
|
|
||||||
uerr_t proz_download_get_join_status(download_t *download)
|
uerr_t proz_download_get_join_status(download_t *download)
|
||||||
{
|
{
|
||||||
|
|
||||||
int building_status;
|
int building_status;
|
||||||
|
|
||||||
pthread_mutex_lock(&download->access_mutex);
|
pthread_mutex_lock(&download->access_mutex);
|
||||||
building_status = download->building;
|
building_status = download->building;
|
||||||
pthread_mutex_unlock(&download->access_mutex);
|
pthread_mutex_unlock(&download->access_mutex);
|
||||||
@ -2135,10 +2126,13 @@ uerr_t proz_download_get_join_status(download_t *download)
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return JOININPROGRESS;
|
return JOININPROGRESS;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
return JOINDONE;
|
return JOINDONE;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
return JOINERR;
|
return JOINERR;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
proz_die("Bad building falg in download structure");
|
proz_die("Bad building falg in download structure");
|
||||||
}
|
}
|
||||||
@ -2149,8 +2143,8 @@ uerr_t proz_download_get_join_status(download_t *download)
|
|||||||
|
|
||||||
float proz_download_get_file_build_percentage(download_t *download)
|
float proz_download_get_file_build_percentage(download_t *download)
|
||||||
{
|
{
|
||||||
|
|
||||||
float percent_done;
|
float percent_done;
|
||||||
|
|
||||||
pthread_mutex_lock(&download->access_mutex);
|
pthread_mutex_lock(&download->access_mutex);
|
||||||
percent_done = 100;
|
percent_done = 100;
|
||||||
pthread_mutex_unlock(&download->access_mutex);
|
pthread_mutex_unlock(&download->access_mutex);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Download routines. */
|
/* Download routines. */
|
||||||
|
|
||||||
/* $Id: download.h,v 1.25 2001/09/30 23:13:50 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef DOWNLOAD_H
|
#ifndef DOWNLOAD_H
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* $Id: ftp-retr.c,v 1.18 2005/01/11 01:49:11 sean Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -85,7 +85,8 @@ uerr_t proz_ftp_get_file(connection_t * connection)
|
|||||||
err = ftp_connect_to_server(connection,
|
err = ftp_connect_to_server(connection,
|
||||||
connection->ftp_proxy->proxy_url.host,
|
connection->ftp_proxy->proxy_url.host,
|
||||||
connection->ftp_proxy->proxy_url.port);
|
connection->ftp_proxy->proxy_url.port);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
err = ftp_connect_to_server(connection, connection->u.host,
|
err = ftp_connect_to_server(connection, connection->u.host,
|
||||||
connection->u.port);
|
connection->u.port);
|
||||||
@ -133,7 +134,8 @@ uerr_t proz_ftp_get_file(connection_t * connection)
|
|||||||
if (err == FTPLOGREFUSED)
|
if (err == FTPLOGREFUSED)
|
||||||
{
|
{
|
||||||
connection_change_status(connection, LOGINFAIL);
|
connection_change_status(connection, LOGINFAIL);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
connection_change_status(connection, REMOTEFATAL);
|
connection_change_status(connection, REMOTEFATAL);
|
||||||
}
|
}
|
||||||
@ -166,12 +168,14 @@ uerr_t proz_ftp_get_file(connection_t * connection)
|
|||||||
connection->u.dir);
|
connection->u.dir);
|
||||||
close_sock(&connection->ctrl_sock);
|
close_sock(&connection->ctrl_sock);
|
||||||
return err;
|
return err;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
proz_debug(_("CWD ok."));
|
proz_debug(_("CWD ok."));
|
||||||
done_with_response(connection);
|
done_with_response(connection);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
proz_debug(_("CWD not needed."));
|
proz_debug(_("CWD not needed."));
|
||||||
|
|
||||||
err = ftp_setup_data_sock_1(connection, &passive_mode);
|
err = ftp_setup_data_sock_1(connection, &passive_mode);
|
||||||
@ -252,7 +256,6 @@ uerr_t ftp_loop(connection_t * connection)
|
|||||||
{
|
{
|
||||||
if (connection->attempts > 0)
|
if (connection->attempts > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (retrying_from_loop == TRUE)
|
if (retrying_from_loop == TRUE)
|
||||||
{
|
{
|
||||||
connection_show_message(connection,
|
connection_show_message(connection,
|
||||||
@ -270,7 +273,8 @@ uerr_t ftp_loop(connection_t * connection)
|
|||||||
_
|
_
|
||||||
("Error while attemting to process download file "));
|
("Error while attemting to process download file "));
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*If we cant resume then reset the connections bytesreceived to 0 */
|
/*If we cant resume then reset the connections bytesreceived to 0 */
|
||||||
connection->remote_bytes_received = 0;
|
connection->remote_bytes_received = 0;
|
||||||
@ -309,8 +313,7 @@ uerr_t ftp_loop(connection_t * connection)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
retrying_from_loop = TRUE;
|
retrying_from_loop = TRUE;
|
||||||
}
|
} while ((connection->attempts < connection->max_attempts)
|
||||||
while ((connection->attempts < connection->max_attempts)
|
|
||||||
|| connection->max_attempts == 0);
|
|| connection->max_attempts == 0);
|
||||||
|
|
||||||
|
|
||||||
@ -326,7 +329,6 @@ or false if it should be passed upwards so that the main download thread can
|
|||||||
restart it when necessary after processing other threads status too */
|
restart it when necessary after processing other threads status too */
|
||||||
boolean ftp_loop_handle_error(uerr_t err)
|
boolean ftp_loop_handle_error(uerr_t err)
|
||||||
{
|
{
|
||||||
|
|
||||||
proz_debug("Error encountered in ftp_loop is %d", err);
|
proz_debug("Error encountered in ftp_loop is %d", err);
|
||||||
if (err == FTPNSFOD || err == FTPLOGREFUSED || err == FTPCONREFUSED
|
if (err == FTPNSFOD || err == FTPLOGREFUSED || err == FTPCONREFUSED
|
||||||
|| err == FWRITEERR || err == FOPENERR || err == FTPCWDFAIL
|
|| err == FWRITEERR || err == FOPENERR || err == FTPCWDFAIL
|
||||||
@ -334,5 +336,4 @@ boolean ftp_loop_handle_error(uerr_t err)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
else
|
else
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* $Id: ftp-retr.h,v 1.6 2001/06/25 12:30:55 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
#ifndef FTP_RETR_H
|
#ifndef FTP_RETR_H
|
||||||
#define FTP_RETR_H
|
#define FTP_RETR_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* FTP support. */
|
/* FTP support. */
|
||||||
|
|
||||||
/* $Id: ftp.c,v 1.55 2005/09/04 00:06:50 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -44,6 +44,7 @@
|
|||||||
static int ftp_get_return(const char *ftp_buffer)
|
static int ftp_get_return(const char *ftp_buffer)
|
||||||
{
|
{
|
||||||
char code[4];
|
char code[4];
|
||||||
|
|
||||||
strncpy(code, ftp_buffer, 3);
|
strncpy(code, ftp_buffer, 3);
|
||||||
code[3] = '\0';
|
code[3] = '\0';
|
||||||
return atoi(code);
|
return atoi(code);
|
||||||
@ -362,7 +363,8 @@ uerr_t ftp_pasv(connection_t * connection, unsigned char *addr)
|
|||||||
|
|
||||||
/* Parse it. */
|
/* Parse it. */
|
||||||
p = (unsigned char *)connection->serv_ret_lines->line;
|
p = (unsigned char *)connection->serv_ret_lines->line;
|
||||||
for (p += 4; *p && !isdigit(*p); p++);
|
for (p += 4; *p && !isdigit(*p); p++)
|
||||||
|
;
|
||||||
|
|
||||||
if (!*p)
|
if (!*p)
|
||||||
return FTPINVPASV;
|
return FTPINVPASV;
|
||||||
@ -469,7 +471,8 @@ uerr_t ftp_pwd(connection_t * connection, char *dir)
|
|||||||
strcpy(dir, l);
|
strcpy(dir, l);
|
||||||
*r = '"';
|
*r = '"';
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if ((r = strchr(connection->serv_ret_lines->line, ' ')) != NULL)
|
if ((r = strchr(connection->serv_ret_lines->line, ' ')) != NULL)
|
||||||
{
|
{
|
||||||
@ -504,9 +507,9 @@ uerr_t ftp_size(connection_t * connection, const char *file, off_t *size)
|
|||||||
{
|
{
|
||||||
sscanf(connection->serv_ret_lines->line + 3, "%lld", size);
|
sscanf(connection->serv_ret_lines->line + 3, "%lld", size);
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
} else if (connection->serv_ret_lines->line[0] == '5') /* An error occured. */
|
}
|
||||||
|
else if (connection->serv_ret_lines->line[0] == '5') /* An error occured. */
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ftp_get_return(connection->serv_ret_lines->line) == 550)
|
if (ftp_get_return(connection->serv_ret_lines->line) == 550)
|
||||||
{
|
{
|
||||||
return FTPNSFOD;
|
return FTPNSFOD;
|
||||||
@ -624,7 +627,8 @@ uerr_t ftp_login(connection_t * connection, const char *username,
|
|||||||
{
|
{
|
||||||
/* No proxy just direct connection. */
|
/* No proxy just direct connection. */
|
||||||
err = ftp_send_msg(connection, "USER %s\r\n", username);
|
err = ftp_send_msg(connection, "USER %s\r\n", username);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
switch (connection->ftp_proxy->type)
|
switch (connection->ftp_proxy->type)
|
||||||
{
|
{
|
||||||
@ -632,21 +636,25 @@ uerr_t ftp_login(connection_t * connection, const char *username,
|
|||||||
err = ftp_send_msg(connection, "USER %s@%s:%d\r\n", username,
|
err = ftp_send_msg(connection, "USER %s@%s:%d\r\n", username,
|
||||||
connection->u.host, connection->u.port);
|
connection->u.host, connection->u.port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USERatPROXYUSERatSITE:
|
case USERatPROXYUSERatSITE:
|
||||||
err = ftp_send_msg(connection, "USER %s@%s@%s:%d\r\n", username,
|
err = ftp_send_msg(connection, "USER %s@%s@%s:%d\r\n", username,
|
||||||
connection->ftp_proxy->username,
|
connection->ftp_proxy->username,
|
||||||
connection->u.host, connection->u.port);
|
connection->u.host, connection->u.port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USERatSITE_PROXYUSER:
|
case USERatSITE_PROXYUSER:
|
||||||
err = ftp_send_msg(connection, "USER %s:%d@%s %s\r\n", username,
|
err = ftp_send_msg(connection, "USER %s:%d@%s %s\r\n", username,
|
||||||
connection->u.host, connection->u.port,
|
connection->u.host, connection->u.port,
|
||||||
connection->ftp_proxy->username);
|
connection->ftp_proxy->username);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROXYUSERatSITE:
|
case PROXYUSERatSITE:
|
||||||
err = ftp_send_msg(connection, "USER %s@%s:%d\r\n",
|
err = ftp_send_msg(connection, "USER %s@%s:%d\r\n",
|
||||||
connection->ftp_proxy->username,
|
connection->ftp_proxy->username,
|
||||||
connection->u.host, connection->u.port);
|
connection->u.host, connection->u.port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Something else, just send PROXY USER. */
|
/* Something else, just send PROXY USER. */
|
||||||
err = ftp_send_msg(connection, "USER %s\r\n",
|
err = ftp_send_msg(connection, "USER %s\r\n",
|
||||||
@ -680,19 +688,23 @@ uerr_t ftp_login(connection_t * connection, const char *username,
|
|||||||
err = ftp_send_msg(connection, "USER %s@%s:%d\r\n", username,
|
err = ftp_send_msg(connection, "USER %s@%s:%d\r\n", username,
|
||||||
connection->u.host, connection->u.port);
|
connection->u.host, connection->u.port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPENSITE:
|
case OPENSITE:
|
||||||
err =
|
err =
|
||||||
ftp_send_msg(connection, "OPEN %s:%d\r\n", connection->u.host,
|
ftp_send_msg(connection, "OPEN %s:%d\r\n", connection->u.host,
|
||||||
connection->u.port);
|
connection->u.port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SITESITE:
|
case SITESITE:
|
||||||
err =
|
err =
|
||||||
ftp_send_msg(connection, "SITE %s:%d\r\n", connection->u.host,
|
ftp_send_msg(connection, "SITE %s:%d\r\n", connection->u.host,
|
||||||
connection->u.port);
|
connection->u.port);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROXYUSERatSITE:
|
case PROXYUSERatSITE:
|
||||||
err = ftp_send_msg(connection, "USER %s\r\n", username);
|
err = ftp_send_msg(connection, "USER %s\r\n", username);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* TODO What is the default here? */
|
/* TODO What is the default here? */
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
@ -721,24 +733,29 @@ uerr_t ftp_login(connection_t * connection, const char *username,
|
|||||||
{
|
{
|
||||||
/* No proxy just direct connection. */
|
/* No proxy just direct connection. */
|
||||||
err = ftp_send_msg(connection, "PASS %s\r\n", passwd);
|
err = ftp_send_msg(connection, "PASS %s\r\n", passwd);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
switch (connection->ftp_proxy->type)
|
switch (connection->ftp_proxy->type)
|
||||||
{
|
{
|
||||||
case USERatSITE:
|
case USERatSITE:
|
||||||
err = ftp_send_msg(connection, "PASS %s\r\n", passwd);
|
err = ftp_send_msg(connection, "PASS %s\r\n", passwd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USERatPROXYUSERatSITE:
|
case USERatPROXYUSERatSITE:
|
||||||
err = ftp_send_msg(connection, "PASS %s@%s\r\n", passwd,
|
err = ftp_send_msg(connection, "PASS %s@%s\r\n", passwd,
|
||||||
connection->ftp_proxy->passwd);
|
connection->ftp_proxy->passwd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USERatSITE_PROXYUSER:
|
case USERatSITE_PROXYUSER:
|
||||||
err = ftp_send_msg(connection, "PASS %s\r\n", passwd);
|
err = ftp_send_msg(connection, "PASS %s\r\n", passwd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROXYUSERatSITE:
|
case PROXYUSERatSITE:
|
||||||
err = ftp_send_msg(connection, "PASS %s\r\n",
|
err = ftp_send_msg(connection, "PASS %s\r\n",
|
||||||
connection->ftp_proxy->passwd);
|
connection->ftp_proxy->passwd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Something else we dont know about. */
|
/* Something else we dont know about. */
|
||||||
err = ftp_send_msg(connection, "PASS %s\r\n",
|
err = ftp_send_msg(connection, "PASS %s\r\n",
|
||||||
@ -809,6 +826,7 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
longstring buffer;
|
longstring buffer;
|
||||||
boolean size_ok;
|
boolean size_ok;
|
||||||
struct ftpparse fp;
|
struct ftpparse fp;
|
||||||
|
|
||||||
/* if we have to use a HTTP proxy call the routine which is defined in http.c
|
/* if we have to use a HTTP proxy call the routine which is defined in http.c
|
||||||
and just return.
|
and just return.
|
||||||
*/
|
*/
|
||||||
@ -842,7 +860,8 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
|
|
||||||
connection_show_message(connection, _("Connected to %s"),
|
connection_show_message(connection, _("Connected to %s"),
|
||||||
connection->ftp_proxy->proxy_url.host);
|
connection->ftp_proxy->proxy_url.host);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
connection_show_message(connection, _("Connecting to %s"),
|
connection_show_message(connection, _("Connecting to %s"),
|
||||||
connection->u.host);
|
connection->u.host);
|
||||||
@ -932,11 +951,13 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
connection->u.dir);
|
connection->u.dir);
|
||||||
close_sock(&connection->ctrl_sock);
|
close_sock(&connection->ctrl_sock);
|
||||||
return err;
|
return err;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
done_with_response(connection);
|
done_with_response(connection);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
connection_show_message(connection, _("CWD not needed"));
|
connection_show_message(connection, _("CWD not needed"));
|
||||||
|
|
||||||
init_response(connection);
|
init_response(connection);
|
||||||
@ -946,7 +967,8 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
connection->resume_support = FALSE;
|
connection->resume_support = FALSE;
|
||||||
connection_show_message(connection, _("REST failed"));
|
connection_show_message(connection, _("REST failed"));
|
||||||
/* NOTE: removed return err; */
|
/* NOTE: removed return err; */
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
connection->resume_support = TRUE;
|
connection->resume_support = TRUE;
|
||||||
connection_show_message(connection, _("REST ok"));
|
connection_show_message(connection, _("REST ok"));
|
||||||
@ -961,9 +983,9 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
/* So connection->u.file is a directory and not a file. */
|
/* So connection->u.file is a directory and not a file. */
|
||||||
connection->file_type = DIRECTORY;
|
connection->file_type = DIRECTORY;
|
||||||
return FTPOK;
|
return FTPOK;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
/* FIXME: The statement below is strictly not true, it could be a symlink
|
/* FIXME: The statement below is strictly not true, it could be a symlink
|
||||||
but for the moment lets leave this as it is, later we will perform a
|
but for the moment lets leave this as it is, later we will perform a
|
||||||
LIST command and detect whether it is a symlink. */
|
LIST command and detect whether it is a symlink. */
|
||||||
@ -995,9 +1017,11 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
case FTPOK:
|
case FTPOK:
|
||||||
size_ok = TRUE;
|
size_ok = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FTPSIZEFAIL:
|
case FTPSIZEFAIL:
|
||||||
size_ok = FALSE;
|
size_ok = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
size_ok = FALSE;
|
size_ok = FALSE;
|
||||||
}
|
}
|
||||||
@ -1080,7 +1104,8 @@ uerr_t proz_ftp_get_url_info(connection_t * connection)
|
|||||||
while ((tmp = strrchr(buffer, '\n')) || (tmp = strrchr(buffer, '\r')))
|
while ((tmp = strrchr(buffer, '\n')) || (tmp = strrchr(buffer, '\r')))
|
||||||
{
|
{
|
||||||
*tmp = 0;
|
*tmp = 0;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
close_sock(&connection->data_sock);
|
close_sock(&connection->data_sock);
|
||||||
close_sock(&connection->ctrl_sock);
|
close_sock(&connection->ctrl_sock);
|
||||||
@ -1128,7 +1153,8 @@ uerr_t ftp_setup_data_sock_1(connection_t * connection,
|
|||||||
{
|
{
|
||||||
proz_debug(_("Server doesn't seem to support PASV"));
|
proz_debug(_("Server doesn't seem to support PASV"));
|
||||||
*passive_mode = FALSE;
|
*passive_mode = FALSE;
|
||||||
} else if (err == FTPOK) /* Server supports PASV. */
|
}
|
||||||
|
else if (err == FTPOK) /* Server supports PASV. */
|
||||||
{
|
{
|
||||||
char dhost[256];
|
char dhost[256];
|
||||||
unsigned short dport;
|
unsigned short dport;
|
||||||
@ -1146,11 +1172,13 @@ uerr_t ftp_setup_data_sock_1(connection_t * connection,
|
|||||||
|
|
||||||
/* Everything seems to be ok. */
|
/* Everything seems to be ok. */
|
||||||
*passive_mode = TRUE;
|
*passive_mode = TRUE;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
done_with_response(connection);
|
done_with_response(connection);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
*passive_mode = FALSE; /* Ok... Since PASV is not to be used. */
|
*passive_mode = FALSE; /* Ok... Since PASV is not to be used. */
|
||||||
|
|
||||||
if (*passive_mode == FALSE)
|
if (*passive_mode == FALSE)
|
||||||
@ -1200,13 +1228,11 @@ uerr_t ftp_get_url_info_loop(connection_t * connection)
|
|||||||
{
|
{
|
||||||
if (connection->attempts > 0 && connection->err != NEWLOCATION)
|
if (connection->attempts > 0 && connection->err != NEWLOCATION)
|
||||||
{
|
{
|
||||||
|
|
||||||
connection_show_message(connection,
|
connection_show_message(connection,
|
||||||
_("Retrying attempt %d in %d seconds"),
|
_("Retrying attempt %d in %d seconds"),
|
||||||
connection->attempts,
|
connection->attempts,
|
||||||
connection->retry_delay.tv_sec);
|
connection->retry_delay.tv_sec);
|
||||||
delay_ms(connection->retry_delay.tv_sec * 1000);
|
delay_ms(connection->retry_delay.tv_sec * 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Push the handler which will cleanup any sockets that are left open */
|
/*Push the handler which will cleanup any sockets that are left open */
|
||||||
@ -1240,9 +1266,7 @@ uerr_t ftp_get_url_info_loop(connection_t * connection)
|
|||||||
connection_show_message(connection, proz_strerror(connection->err));
|
connection_show_message(connection, proz_strerror(connection->err));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} while ((connection->attempts < connection->max_attempts)
|
||||||
}
|
|
||||||
while ((connection->attempts < connection->max_attempts)
|
|
||||||
|| connection->max_attempts == 0);
|
|| connection->max_attempts == 0);
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* FTP support. */
|
/* FTP support. */
|
||||||
|
|
||||||
/* $Id: ftp.h,v 1.35 2005/09/04 00:06:50 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef FTP_H
|
#ifndef FTP_H
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
long getlong(char *buf, int len)
|
long getlong(char *buf, int len)
|
||||||
{
|
{
|
||||||
long u = 0;
|
long u = 0;
|
||||||
|
|
||||||
while (len-- > 0)
|
while (len-- > 0)
|
||||||
u = u * 10 + (*buf++ - '0');
|
u = u * 10 + (*buf++ - '0');
|
||||||
return u;
|
return u;
|
||||||
@ -71,37 +72,56 @@ char * get_nextfield (char ** pstr)
|
|||||||
char * p = *pstr;
|
char * p = *pstr;
|
||||||
|
|
||||||
char * start = NULL;
|
char * start = NULL;
|
||||||
if (!pstr || !*pstr) return NULL;
|
|
||||||
while (1) {
|
if (!pstr || !*pstr)
|
||||||
|
return NULL;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
/* Strip white space and other delimiters */
|
/* Strip white space and other delimiters */
|
||||||
while (*p && (isspace((int) *p) || *p==',' || *p==';' || *p=='=')) p++;
|
while (*p && (isspace((int)*p) || *p == ',' || *p == ';' || *p == '='))
|
||||||
if (!*p) {
|
p++;
|
||||||
|
if (!*p)
|
||||||
|
{
|
||||||
*pstr = p;
|
*pstr = p;
|
||||||
return NULL; /* No field */
|
return NULL; /* No field */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p == '"') { /* quoted field */
|
if (*p == '"') /* quoted field */
|
||||||
|
{
|
||||||
start = ++p;
|
start = ++p;
|
||||||
for (; *p && *p != '"'; p++)
|
for (; *p && *p != '"'; p++)
|
||||||
if (*p == '\\' && *(p+1)) p++; /* Skip escaped chars */
|
if (*p == '\\' && *(p + 1))
|
||||||
|
p++;
|
||||||
|
/* Skip escaped chars */
|
||||||
break; /* kr95-10-9: needs to stop here */
|
break; /* kr95-10-9: needs to stop here */
|
||||||
} else if (*p == '<') { /* quoted field */
|
}
|
||||||
|
else if (*p == '<') /* quoted field */
|
||||||
|
{
|
||||||
start = ++p;
|
start = ++p;
|
||||||
for (; *p && *p != '>'; p++)
|
for (; *p && *p != '>'; p++)
|
||||||
if (*p == '\\' && *(p+1)) p++; /* Skip escaped chars */
|
if (*p == '\\' && *(p + 1))
|
||||||
break; /* kr95-10-9: needs to stop here */
|
|
||||||
} else if (*p == '(') { /* Comment */
|
|
||||||
for(;*p && *p!=')'; p++)
|
|
||||||
if (*p == '\\' && *(p+1)) p++; /* Skip escaped chars */
|
|
||||||
p++;
|
p++;
|
||||||
} else { /* Spool field */
|
/* Skip escaped chars */
|
||||||
|
break; /* kr95-10-9: needs to stop here */
|
||||||
|
}
|
||||||
|
else if (*p == '(') /* Comment */
|
||||||
|
{
|
||||||
|
for (; *p && *p != ')'; p++)
|
||||||
|
if (*p == '\\' && *(p + 1))
|
||||||
|
p++;
|
||||||
|
/* Skip escaped chars */
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
else /* Spool field */
|
||||||
|
{
|
||||||
start = p;
|
start = p;
|
||||||
while (*p && !isspace((int)*p) && *p != ',' && *p != ';' && *p != '=')
|
while (*p && !isspace((int)*p) && *p != ',' && *p != ';' && *p != '=')
|
||||||
p++;
|
p++;
|
||||||
break; /* Got it */
|
break; /* Got it */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*p) *p++ = '\0';
|
if (*p)
|
||||||
|
*p++ = '\0';
|
||||||
*pstr = p;
|
*pstr = p;
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
@ -110,12 +130,12 @@ char * get_nextfield (char ** pstr)
|
|||||||
|
|
||||||
uerr_t ftp_parse(ftpparse *fp, char *buf, int len)
|
uerr_t ftp_parse(ftpparse *fp, char *buf, int len)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *cp;
|
char *cp;
|
||||||
char *token;
|
char *token;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char *date;
|
char *date;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fp->filename = 0;
|
fp->filename = 0;
|
||||||
fp->namelen = 0;
|
fp->namelen = 0;
|
||||||
// fp->flagtrycwd = 0;
|
// fp->flagtrycwd = 0;
|
||||||
@ -134,7 +154,8 @@ uerr_t ftp_parse(ftpparse *fp,char *buf,int len)
|
|||||||
if (len < 2) /* an empty name in EPLF, with no info, could be 2 chars */
|
if (len < 2) /* an empty name in EPLF, with no info, could be 2 chars */
|
||||||
return FTPPARSENOTEXIST;
|
return FTPPARSENOTEXIST;
|
||||||
|
|
||||||
switch(*buf) {
|
switch (*buf)
|
||||||
|
{
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'c':
|
case 'c':
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -160,9 +181,12 @@ uerr_t ftp_parse(ftpparse *fp,char *buf,int len)
|
|||||||
/* "drwxrwxr-x folder 2 May 10 1996 network"
|
/* "drwxrwxr-x folder 2 May 10 1996 network"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (*buf == 'd') fp->filetype = DIRECTORY;
|
if (*buf == 'd')
|
||||||
if (*buf == '-') fp->filetype = DIRECTORY;
|
fp->filetype = DIRECTORY;
|
||||||
if (*buf == 'l') fp->filetype = SYMBOLIC_LINK;
|
if (*buf == '-')
|
||||||
|
fp->filetype = DIRECTORY;
|
||||||
|
if (*buf == 'l')
|
||||||
|
fp->filetype = SYMBOLIC_LINK;
|
||||||
ptr = cp = strdup(buf);
|
ptr = cp = strdup(buf);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
@ -176,17 +200,21 @@ uerr_t ftp_parse(ftpparse *fp,char *buf,int len)
|
|||||||
** This field can either be group or size. We find out by looking at the
|
** This field can either be group or size. We find out by looking at the
|
||||||
** next field. If this is a non-digit then this field is the size.
|
** next field. If this is a non-digit then this field is the size.
|
||||||
*/
|
*/
|
||||||
while (*cp && isspace((int) *cp)) cp++;
|
while (*cp && isspace((int)*cp))
|
||||||
if (isdigit((int) *cp)) {
|
cp++;
|
||||||
|
if (isdigit((int)*cp))
|
||||||
|
{
|
||||||
token = get_nextfield(&cp);
|
token = get_nextfield(&cp);
|
||||||
while (*cp && isspace((int) *cp)) cp++;
|
while (*cp && isspace((int)*cp))
|
||||||
|
cp++;
|
||||||
}
|
}
|
||||||
//if it is a filename
|
//if it is a filename
|
||||||
fp->filesize = strtol(token, NULL, 10);
|
fp->filesize = strtol(token, NULL, 10);
|
||||||
proz_debug("FTP file size is %ld", fp->filesize);
|
proz_debug("FTP file size is %ld", fp->filesize);
|
||||||
|
|
||||||
|
|
||||||
while (*cp && isspace((int) *cp)) cp++;
|
while (*cp && isspace((int)*cp))
|
||||||
|
cp++;
|
||||||
assert(cp + 12 < ptr + len);
|
assert(cp + 12 < ptr + len);
|
||||||
date = cp;
|
date = cp;
|
||||||
cp += 12;
|
cp += 12;
|
||||||
@ -196,11 +224,10 @@ uerr_t ftp_parse(ftpparse *fp,char *buf,int len)
|
|||||||
proz_debug("LIST date is %s", fp->date_str);
|
proz_debug("LIST date is %s", fp->date_str);
|
||||||
|
|
||||||
return FTPPARSEOK;
|
return FTPPARSEOK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FTPPARSEFAIL;
|
return FTPPARSEFAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,18 +235,16 @@ uerr_t ftp_parse(ftpparse *fp,char *buf,int len)
|
|||||||
|
|
||||||
time_t parse_time(const char * str)
|
time_t parse_time(const char * str)
|
||||||
{
|
{
|
||||||
|
|
||||||
char * p;
|
char * p;
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
if (!str) return 0;
|
if (!str)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if ((p = strchr(str, ',')))
|
if ((p = strchr(str, ',')))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* FTP LIST command parsing code. */
|
/* FTP LIST command parsing code. */
|
||||||
|
|
||||||
/* $Id: ftpparse.h,v 1.15 2005/08/06 17:07:35 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef FTPPARSE_H
|
#ifndef FTPPARSE_H
|
||||||
|
@ -82,6 +82,7 @@ ftps_request_t * proz_ftps_request_init(
|
|||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILESEARCH_RU:
|
case FILESEARCH_RU:
|
||||||
url = prepare_filesearching_url(request, ftps_loc, num_req_mirrors);
|
url = prepare_filesearching_url(request, ftps_loc, num_req_mirrors);
|
||||||
if (url == 0)
|
if (url == 0)
|
||||||
@ -90,6 +91,7 @@ ftps_request_t * proz_ftps_request_init(
|
|||||||
/*NOTE pasing zero as the status change mutes as we dont need it here */
|
/*NOTE pasing zero as the status change mutes as we dont need it here */
|
||||||
request->connection = proz_connection_init(url, 0);
|
request->connection = proz_connection_init(url, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
proz_debug("Unsupported FTP search server type");
|
proz_debug("Unsupported FTP search server type");
|
||||||
proz_die("Unsupported FTP search server type");
|
proz_die("Unsupported FTP search server type");
|
||||||
@ -181,15 +183,16 @@ urlinfo *prepare_filesearching_url(ftps_request_t * request, char *ftps_loc,
|
|||||||
|
|
||||||
uerr_t parse_html_mirror_list(ftps_request_t * request, char *p)
|
uerr_t parse_html_mirror_list(ftps_request_t * request, char *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (request->server_type)
|
switch (request->server_type)
|
||||||
{
|
{
|
||||||
case LYCOS:
|
case LYCOS:
|
||||||
return parse_lycos_html_mirror_list(request, p);
|
return parse_lycos_html_mirror_list(request, p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILESEARCH_RU:
|
case FILESEARCH_RU:
|
||||||
return parse_filesearching_html_mirror_list(request, p);
|
return parse_filesearching_html_mirror_list(request, p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
proz_debug("Unsupported FTP search server type");
|
proz_debug("Unsupported FTP search server type");
|
||||||
proz_die("Unsupported FTP search server type");
|
proz_die("Unsupported FTP search server type");
|
||||||
@ -199,7 +202,6 @@ uerr_t parse_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
|
|
||||||
uerr_t parse_lycos_html_mirror_list(ftps_request_t * request, char *p)
|
uerr_t parse_lycos_html_mirror_list(ftps_request_t * request, char *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ftp_mirror **pmirrors = &request->mirrors;
|
struct ftp_mirror **pmirrors = &request->mirrors;
|
||||||
int *num_servers = &request->num_mirrors;
|
int *num_servers = &request->num_mirrors;
|
||||||
char *p1, *p2, *i = 0, *j;
|
char *p1, *p2, *i = 0, *j;
|
||||||
@ -226,7 +228,6 @@ uerr_t parse_lycos_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
|
|
||||||
if (num_pre == 1)
|
if (num_pre == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((i = strstr(p, "<PRE>")) == NULL)
|
if ((i = strstr(p, "<PRE>")) == NULL)
|
||||||
{
|
{
|
||||||
proz_debug("nomatches found");
|
proz_debug("nomatches found");
|
||||||
@ -240,7 +241,8 @@ uerr_t parse_lycos_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
proz_debug("nomatches found");
|
proz_debug("nomatches found");
|
||||||
return MIRPARSEFAIL;
|
return MIRPARSEFAIL;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*search for the reported hits text */
|
/*search for the reported hits text */
|
||||||
char *rep_hits;
|
char *rep_hits;
|
||||||
@ -358,7 +360,6 @@ uerr_t parse_lycos_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
|
|
||||||
for (k = 0; k < *num_servers; k++)
|
for (k = 0; k < *num_servers; k++)
|
||||||
{
|
{
|
||||||
|
|
||||||
ftp_mirrors[k].full_name =
|
ftp_mirrors[k].full_name =
|
||||||
(char *)kmalloc(strlen(ftp_mirrors[k].server_name) +
|
(char *)kmalloc(strlen(ftp_mirrors[k].server_name) +
|
||||||
strlen(ftp_mirrors[k].paths[0].path) +
|
strlen(ftp_mirrors[k].paths[0].path) +
|
||||||
@ -379,7 +380,6 @@ uerr_t parse_lycos_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
|
|
||||||
uerr_t parse_filesearching_html_mirror_list(ftps_request_t * request, char *p)
|
uerr_t parse_filesearching_html_mirror_list(ftps_request_t * request, char *p)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct ftp_mirror **pmirrors = &request->mirrors;
|
struct ftp_mirror **pmirrors = &request->mirrors;
|
||||||
int *num_servers = &request->num_mirrors;
|
int *num_servers = &request->num_mirrors;
|
||||||
char *p1, *p2, *i = 0, *j;
|
char *p1, *p2, *i = 0, *j;
|
||||||
@ -406,7 +406,6 @@ uerr_t parse_filesearching_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
|
|
||||||
if (num_pre == 1)
|
if (num_pre == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((i = strstr(p, "<pre class=list>")) == NULL)
|
if ((i = strstr(p, "<pre class=list>")) == NULL)
|
||||||
{
|
{
|
||||||
proz_debug("nomatches found");
|
proz_debug("nomatches found");
|
||||||
@ -420,7 +419,8 @@ uerr_t parse_filesearching_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
proz_debug("nomatches found");
|
proz_debug("nomatches found");
|
||||||
return MIRPARSEFAIL;
|
return MIRPARSEFAIL;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*search for the reported hits text */
|
/*search for the reported hits text */
|
||||||
char *rep_hits;
|
char *rep_hits;
|
||||||
@ -543,7 +543,6 @@ uerr_t parse_filesearching_html_mirror_list(ftps_request_t * request, char *p)
|
|||||||
|
|
||||||
for (k = 0; k < *num_servers; k++)
|
for (k = 0; k < *num_servers; k++)
|
||||||
{
|
{
|
||||||
|
|
||||||
ftp_mirrors[k].full_name =
|
ftp_mirrors[k].full_name =
|
||||||
(char *)kmalloc(strlen(ftp_mirrors[k].server_name) +
|
(char *)kmalloc(strlen(ftp_mirrors[k].server_name) +
|
||||||
strlen(ftp_mirrors[k].paths[0].path) +
|
strlen(ftp_mirrors[k].paths[0].path) +
|
||||||
@ -603,7 +602,8 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
connection_change_status(connection, REMOTEFATAL);
|
connection_change_status(connection, REMOTEFATAL);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
connection_show_message(connection, _("Connecting to %s"),
|
connection_show_message(connection, _("Connecting to %s"),
|
||||||
connection->u.host);
|
connection->u.host);
|
||||||
@ -642,7 +642,8 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
||||||
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
||||||
proz_debug(_("Authentification string=%s"), www_auth);
|
proz_debug(_("Authentification string=%s"), www_auth);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
www_auth = 0;
|
www_auth = 0;
|
||||||
|
|
||||||
if (http_use_proxy(connection))
|
if (http_use_proxy(connection))
|
||||||
@ -659,7 +660,8 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
{
|
{
|
||||||
remote_port = NULL;
|
remote_port = NULL;
|
||||||
remote_port_len = 0;
|
remote_port_len = 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
remote_port = (char *)alloca(64);
|
remote_port = (char *)alloca(64);
|
||||||
remote_port_len = sprintf(remote_port, ":%d", connection->u.port);
|
remote_port_len = sprintf(remote_port, ":%d", connection->u.port);
|
||||||
@ -676,7 +678,8 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
{
|
{
|
||||||
location = (char *)alloca(strlen(connection->u.url) + 1);
|
location = (char *)alloca(strlen(connection->u.url) + 1);
|
||||||
strcpy(location, connection->u.url);
|
strcpy(location, connection->u.url);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
location = (char *)alloca(strlen(connection->u.path) + 1);
|
location = (char *)alloca(strlen(connection->u.path) + 1);
|
||||||
strcpy(location, connection->u.path);
|
strcpy(location, connection->u.path);
|
||||||
@ -739,7 +742,6 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
krecv(connection->data_sock, buffer, sizeof(buffer), 0,
|
krecv(connection->data_sock, buffer, sizeof(buffer), 0,
|
||||||
&connection->xfer_timeout);
|
&connection->xfer_timeout);
|
||||||
@ -751,8 +753,7 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
p = p2;
|
p = p2;
|
||||||
}
|
}
|
||||||
total += ret;
|
total += ret;
|
||||||
}
|
} while (ret > 0);
|
||||||
while (ret > 0);
|
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
@ -777,7 +778,6 @@ uerr_t get_mirror_info(connection_t * connection, char **ret_buf)
|
|||||||
|
|
||||||
char *find_ahref(char *buf)
|
char *find_ahref(char *buf)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(strcasestr(buf, "<A HREF="));
|
return(strcasestr(buf, "<A HREF="));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,7 +835,8 @@ char *grow_buffer(char *buf_start, char *cur_pos, int *buf_len,
|
|||||||
p = krealloc(buf_start, *buf_len + INIT_SIZE);
|
p = krealloc(buf_start, *buf_len + INIT_SIZE);
|
||||||
*buf_len += INIT_SIZE;
|
*buf_len += INIT_SIZE;
|
||||||
return p;
|
return p;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return buf_start;
|
return buf_start;
|
||||||
}
|
}
|
||||||
@ -852,9 +853,6 @@ void proz_get_complete_mirror_list(ftps_request_t * request)
|
|||||||
(void *)&get_complete_mirror_list,
|
(void *)&get_complete_mirror_list,
|
||||||
(void *)request) != 0)
|
(void *)request) != 0)
|
||||||
proz_die(_("Error: Not enough system resources"));
|
proz_die(_("Error: Not enough system resources"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -911,7 +909,8 @@ uerr_t get_complete_mirror_list(ftps_request_t * request)
|
|||||||
request->info_running = FALSE;
|
request->info_running = FALSE;
|
||||||
pthread_mutex_unlock(&request->access_mutex);
|
pthread_mutex_unlock(&request->access_mutex);
|
||||||
return(request->err = HERR);
|
return(request->err = HERR);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
connection_show_message(request->connection,
|
connection_show_message(request->connection,
|
||||||
_("Redirected to => %s"),
|
_("Redirected to => %s"),
|
||||||
constructed_newloc);
|
constructed_newloc);
|
||||||
@ -919,8 +918,7 @@ uerr_t get_complete_mirror_list(ftps_request_t * request)
|
|||||||
kfree(constructed_newloc);
|
kfree(constructed_newloc);
|
||||||
request->err = NEWLOCATION;
|
request->err = NEWLOCATION;
|
||||||
}
|
}
|
||||||
}
|
} while (request->err == NEWLOCATION);
|
||||||
while (request->err == NEWLOCATION);
|
|
||||||
|
|
||||||
/*TODO handle and process the redirection here */
|
/*TODO handle and process the redirection here */
|
||||||
if (request->err != HOK)
|
if (request->err != HOK)
|
||||||
@ -937,13 +935,13 @@ uerr_t get_complete_mirror_list(ftps_request_t * request)
|
|||||||
request->info_running = FALSE;
|
request->info_running = FALSE;
|
||||||
pthread_mutex_unlock(&request->access_mutex);
|
pthread_mutex_unlock(&request->access_mutex);
|
||||||
return request->err;
|
return request->err;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
boolean proz_request_info_running(ftps_request_t * request)
|
boolean proz_request_info_running(ftps_request_t * request)
|
||||||
{
|
{
|
||||||
boolean ret;
|
boolean ret;
|
||||||
|
|
||||||
pthread_mutex_lock(&request->access_mutex);
|
pthread_mutex_lock(&request->access_mutex);
|
||||||
ret = request->info_running;
|
ret = request->info_running;
|
||||||
pthread_mutex_unlock(&request->access_mutex);
|
pthread_mutex_unlock(&request->access_mutex);
|
||||||
@ -953,6 +951,7 @@ boolean proz_request_info_running(ftps_request_t * request)
|
|||||||
boolean proz_request_mass_ping_running(ftps_request_t * request)
|
boolean proz_request_mass_ping_running(ftps_request_t * request)
|
||||||
{
|
{
|
||||||
boolean ret;
|
boolean ret;
|
||||||
|
|
||||||
pthread_mutex_lock(&request->access_mutex);
|
pthread_mutex_lock(&request->access_mutex);
|
||||||
ret = request->mass_ping_running;
|
ret = request->mass_ping_running;
|
||||||
pthread_mutex_unlock(&request->access_mutex);
|
pthread_mutex_unlock(&request->access_mutex);
|
||||||
@ -964,7 +963,6 @@ boolean proz_request_mass_ping_running(ftps_request_t * request)
|
|||||||
ftp_mirror_t *reprocess_mirror_list(ftp_mirror_t * mirrors,
|
ftp_mirror_t *reprocess_mirror_list(ftp_mirror_t * mirrors,
|
||||||
int *num_servers)
|
int *num_servers)
|
||||||
{
|
{
|
||||||
|
|
||||||
ftp_mirror_t *ftp_mirrors;
|
ftp_mirror_t *ftp_mirrors;
|
||||||
int i, j;
|
int i, j;
|
||||||
int num_new_servers = 0;
|
int num_new_servers = 0;
|
||||||
@ -1067,6 +1065,7 @@ int compare_two_servers(const void *a, const void *b)
|
|||||||
void proz_sort_mirror_list(ftp_mirror_t * mirrors, int num_servers)
|
void proz_sort_mirror_list(ftp_mirror_t * mirrors, int num_servers)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
qsort(mirrors, num_servers, sizeof(ftp_mirror_t), compare_two_servers);
|
qsort(mirrors, num_servers, sizeof(ftp_mirror_t), compare_two_servers);
|
||||||
for (i = 0; i < num_servers; i++)
|
for (i = 0; i < num_servers; i++)
|
||||||
proz_debug("Mirror = %s, time =%d", mirrors[i].server_name,
|
proz_debug("Mirror = %s, time =%d", mirrors[i].server_name,
|
||||||
@ -1079,9 +1078,9 @@ void proz_sort_mirror_list(ftp_mirror_t * mirrors, int num_servers)
|
|||||||
int ftpsearch_get_server_position(ftps_request_t * request, char *server)
|
int ftpsearch_get_server_position(ftps_request_t * request, char *server)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < request->num_mirrors; i++)
|
for (i = 0; i < request->num_mirrors; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (strcmp(request->mirrors[i].server_name, server) == 0)
|
if (strcmp(request->mirrors[i].server_name, server) == 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -1105,8 +1104,6 @@ int ftpsearch_get_path_position(ftps_request_t * request, char *server,
|
|||||||
proz_debug("path to check is %s", path);
|
proz_debug("path to check is %s", path);
|
||||||
if (strcmp(request->mirrors[pos].paths[i].path, path) == 0)
|
if (strcmp(request->mirrors[pos].paths[i].path, path) == 0)
|
||||||
return i;
|
return i;
|
||||||
|
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* $Id: http-retr.c,v 1.20 2005/03/31 20:10:57 sean Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "prozilla.h"
|
#include "prozilla.h"
|
||||||
@ -79,7 +79,8 @@ uerr_t proz_http_get_file(connection_t * connection)
|
|||||||
connection_change_status(connection, REMOTEFATAL);
|
connection_change_status(connection, REMOTEFATAL);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
connection_show_message(connection, _("Connecting to %s"),
|
connection_show_message(connection, _("Connecting to %s"),
|
||||||
connection->u.host);
|
connection->u.host);
|
||||||
@ -118,7 +119,8 @@ uerr_t proz_http_get_file(connection_t * connection)
|
|||||||
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
||||||
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
||||||
proz_debug(_("Authentification string=%s"), www_auth);
|
proz_debug(_("Authentification string=%s"), www_auth);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
www_auth = 0;
|
www_auth = 0;
|
||||||
|
|
||||||
if (http_use_proxy(connection))
|
if (http_use_proxy(connection))
|
||||||
@ -135,7 +137,8 @@ uerr_t proz_http_get_file(connection_t * connection)
|
|||||||
{
|
{
|
||||||
remote_port = NULL;
|
remote_port = NULL;
|
||||||
remote_port_len = 0;
|
remote_port_len = 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
remote_port = (char *)alloca(64);
|
remote_port = (char *)alloca(64);
|
||||||
remote_port_len = sprintf(remote_port, ":%d", connection->u.port);
|
remote_port_len = sprintf(remote_port, ":%d", connection->u.port);
|
||||||
@ -159,7 +162,8 @@ uerr_t proz_http_get_file(connection_t * connection)
|
|||||||
{
|
{
|
||||||
location = (char *)alloca(strlen(connection->u.url) + 1);
|
location = (char *)alloca(strlen(connection->u.url) + 1);
|
||||||
strcpy(location, connection->u.url);
|
strcpy(location, connection->u.url);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
location = (char *)alloca(strlen(connection->u.path) + 1);
|
location = (char *)alloca(strlen(connection->u.path) + 1);
|
||||||
strcpy(location, connection->u.path);
|
strcpy(location, connection->u.path);
|
||||||
@ -260,6 +264,7 @@ of maximum tries for the connection is realised
|
|||||||
uerr_t http_loop(connection_t * connection)
|
uerr_t http_loop(connection_t * connection)
|
||||||
{
|
{
|
||||||
boolean retrying_from_loop = FALSE;
|
boolean retrying_from_loop = FALSE;
|
||||||
|
|
||||||
assert(connection->max_attempts >= 0);
|
assert(connection->max_attempts >= 0);
|
||||||
assert(connection->attempts >= 0);
|
assert(connection->attempts >= 0);
|
||||||
|
|
||||||
@ -269,7 +274,6 @@ uerr_t http_loop(connection_t * connection)
|
|||||||
{
|
{
|
||||||
if (connection->attempts > 0)
|
if (connection->attempts > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (retrying_from_loop == TRUE)
|
if (retrying_from_loop == TRUE)
|
||||||
{
|
{
|
||||||
connection_show_message(connection,
|
connection_show_message(connection,
|
||||||
@ -287,7 +291,8 @@ uerr_t http_loop(connection_t * connection)
|
|||||||
_
|
_
|
||||||
("Error while attemting to process download file "));
|
("Error while attemting to process download file "));
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*If we cant resume then reset the connections bytesreceived to 0 */
|
/*If we cant resume then reset the connections bytesreceived to 0 */
|
||||||
connection->remote_bytes_received = 0;
|
connection->remote_bytes_received = 0;
|
||||||
@ -324,9 +329,7 @@ uerr_t http_loop(connection_t * connection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
retrying_from_loop = TRUE;
|
retrying_from_loop = TRUE;
|
||||||
|
} while ((connection->attempts < connection->max_attempts)
|
||||||
}
|
|
||||||
while ((connection->attempts < connection->max_attempts)
|
|
||||||
|| connection->max_attempts == 0);
|
|| connection->max_attempts == 0);
|
||||||
|
|
||||||
|
|
||||||
@ -336,7 +339,6 @@ uerr_t http_loop(connection_t * connection)
|
|||||||
connection->attempts);
|
connection->attempts);
|
||||||
|
|
||||||
return connection->err;
|
return connection->err;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -361,7 +363,6 @@ boolean http_loop_handle_error(uerr_t err)
|
|||||||
*/
|
*/
|
||||||
uerr_t ftp_get_file_from_http_proxy(connection_t * connection)
|
uerr_t ftp_get_file_from_http_proxy(connection_t * connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
int remote_port_len;
|
int remote_port_len;
|
||||||
char *user, *passwd, *www_auth = NULL, *proxy_auth = NULL, *range =
|
char *user, *passwd, *www_auth = NULL, *proxy_auth = NULL, *range =
|
||||||
@ -424,7 +425,8 @@ uerr_t ftp_get_file_from_http_proxy(connection_t * connection)
|
|||||||
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
||||||
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
||||||
proz_debug(_("Authentification string=%s"), www_auth);
|
proz_debug(_("Authentification string=%s"), www_auth);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
www_auth = 0;
|
www_auth = 0;
|
||||||
|
|
||||||
if (strlen(connection->ftp_proxy->username)
|
if (strlen(connection->ftp_proxy->username)
|
||||||
@ -487,11 +489,13 @@ uerr_t ftp_get_file_from_http_proxy(connection_t * connection)
|
|||||||
{
|
{
|
||||||
connection_change_status(connection, LOGINFAIL);
|
connection_change_status(connection, LOGINFAIL);
|
||||||
return FTPLOGREFUSED;
|
return FTPLOGREFUSED;
|
||||||
} else if (err == HTTPNSFOD)
|
}
|
||||||
|
else if (err == HTTPNSFOD)
|
||||||
{
|
{
|
||||||
connection_change_status(connection, REMOTEFATAL);
|
connection_change_status(connection, REMOTEFATAL);
|
||||||
return FTPNSFOD;
|
return FTPNSFOD;
|
||||||
} else if (err != HOK)
|
}
|
||||||
|
else if (err != HOK)
|
||||||
{
|
{
|
||||||
connection_change_status(connection, REMOTEFATAL);
|
connection_change_status(connection, REMOTEFATAL);
|
||||||
return FTPERR;
|
return FTPERR;
|
||||||
@ -526,5 +530,4 @@ uerr_t ftp_get_file_from_http_proxy(connection_t * connection)
|
|||||||
return FTPOK;
|
return FTPOK;
|
||||||
else
|
else
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
/* $Id: http-retr.h,v 1.5 2001/06/25 12:30:56 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef HTTP_RETR_H
|
#ifndef HTTP_RETR_H
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* HTTP support. */
|
/* HTTP support. */
|
||||||
|
|
||||||
/* $Id: http.c,v 1.22 2005/03/31 20:10:57 sean Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -154,7 +154,8 @@ uerr_t fetch_next_header(int fd, char **hdr, struct timeval * timeout)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (res == 0)
|
}
|
||||||
|
else if (res == 0)
|
||||||
return HEOF;
|
return HEOF;
|
||||||
else
|
else
|
||||||
return HERR;
|
return HERR;
|
||||||
@ -216,7 +217,8 @@ int hparsestatline(const char *hdr, const char **rp)
|
|||||||
*rp = hdr + 3;
|
*rp = hdr + 3;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
*rp = hdr + 4;
|
*rp = hdr + 4;
|
||||||
|
|
||||||
return statcode;
|
return statcode;
|
||||||
@ -409,7 +411,8 @@ uerr_t http_fetch_headers(connection_t * connection, http_stat_t * hs,
|
|||||||
kfree(all_headers);
|
kfree(all_headers);
|
||||||
|
|
||||||
return HEOF;
|
return HEOF;
|
||||||
} else if (err == HERR)
|
}
|
||||||
|
else if (err == HERR)
|
||||||
{
|
{
|
||||||
proz_debug(_("Read error in headers"));
|
proz_debug(_("Read error in headers"));
|
||||||
|
|
||||||
@ -574,7 +577,8 @@ uerr_t proz_http_get_url_info(connection_t * connection)
|
|||||||
connection->http_proxy->proxy_url.host);
|
connection->http_proxy->proxy_url.host);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
connection_show_message(connection, _("Connecting to %s"),
|
connection_show_message(connection, _("Connecting to %s"),
|
||||||
connection->u.host);
|
connection->u.host);
|
||||||
@ -612,7 +616,8 @@ uerr_t proz_http_get_url_info(connection_t * connection)
|
|||||||
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
||||||
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
||||||
proz_debug(_("Authentification string=%s"), www_auth);
|
proz_debug(_("Authentification string=%s"), www_auth);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
www_auth = 0;
|
www_auth = 0;
|
||||||
|
|
||||||
if (http_use_proxy(connection))
|
if (http_use_proxy(connection))
|
||||||
@ -629,7 +634,8 @@ uerr_t proz_http_get_url_info(connection_t * connection)
|
|||||||
{
|
{
|
||||||
remote_port = NULL;
|
remote_port = NULL;
|
||||||
remote_port_len = 0;
|
remote_port_len = 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
remote_port = (char *)alloca(64);
|
remote_port = (char *)alloca(64);
|
||||||
remote_port_len = sprintf(remote_port, ":%d", connection->u.port);
|
remote_port_len = sprintf(remote_port, ":%d", connection->u.port);
|
||||||
@ -647,7 +653,8 @@ uerr_t proz_http_get_url_info(connection_t * connection)
|
|||||||
{
|
{
|
||||||
location = (char *)alloca(strlen(connection->u.url) + 1);
|
location = (char *)alloca(strlen(connection->u.url) + 1);
|
||||||
strcpy(location, connection->u.url);
|
strcpy(location, connection->u.url);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
location = (char *)alloca(strlen(connection->u.path) + 1);
|
location = (char *)alloca(strlen(connection->u.path) + 1);
|
||||||
strcpy(location, connection->u.path);
|
strcpy(location, connection->u.path);
|
||||||
@ -704,7 +711,6 @@ uerr_t proz_http_get_url_info(connection_t * connection)
|
|||||||
/*Loops for connection->attempts */
|
/*Loops for connection->attempts */
|
||||||
uerr_t http_get_url_info_loop(connection_t * connection)
|
uerr_t http_get_url_info_loop(connection_t * connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_mutex_lock(&connection->access_mutex);
|
pthread_mutex_lock(&connection->access_mutex);
|
||||||
connection->running = TRUE;
|
connection->running = TRUE;
|
||||||
pthread_mutex_unlock(&connection->access_mutex);
|
pthread_mutex_unlock(&connection->access_mutex);
|
||||||
@ -714,7 +720,6 @@ uerr_t http_get_url_info_loop(connection_t * connection)
|
|||||||
{
|
{
|
||||||
if (connection->attempts > 0 && connection->err != NEWLOCATION)
|
if (connection->attempts > 0 && connection->err != NEWLOCATION)
|
||||||
{
|
{
|
||||||
|
|
||||||
connection_show_message(connection,
|
connection_show_message(connection,
|
||||||
_("Retrying...Attempt %d in %d seconds"),
|
_("Retrying...Attempt %d in %d seconds"),
|
||||||
connection->attempts,
|
connection->attempts,
|
||||||
@ -756,9 +761,7 @@ uerr_t http_get_url_info_loop(connection_t * connection)
|
|||||||
connection_show_message(connection, proz_strerror(connection->err));
|
connection_show_message(connection, proz_strerror(connection->err));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} while ((connection->attempts < connection->max_attempts)
|
||||||
}
|
|
||||||
while ((connection->attempts < connection->max_attempts)
|
|
||||||
|| connection->max_attempts == 0);
|
|| connection->max_attempts == 0);
|
||||||
|
|
||||||
|
|
||||||
@ -782,7 +785,6 @@ uerr_t http_get_url_info_loop(connection_t * connection)
|
|||||||
|
|
||||||
uerr_t ftp_get_url_info_from_http_proxy(connection_t * connection)
|
uerr_t ftp_get_url_info_from_http_proxy(connection_t * connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
int remote_port_len;
|
int remote_port_len;
|
||||||
char *user, *passwd, *www_auth = NULL, *proxy_auth =
|
char *user, *passwd, *www_auth = NULL, *proxy_auth =
|
||||||
@ -829,7 +831,8 @@ uerr_t ftp_get_url_info_from_http_proxy(connection_t * connection)
|
|||||||
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
www_auth = get_basic_auth_str(user, passwd, "Authorization");
|
||||||
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
proz_debug(_("Authenticating as user %s password %s"), user, passwd);
|
||||||
proz_debug(_("Authentification string=%s"), www_auth);
|
proz_debug(_("Authentification string=%s"), www_auth);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
www_auth = 0;
|
www_auth = 0;
|
||||||
|
|
||||||
if (strlen(connection->ftp_proxy->username)
|
if (strlen(connection->ftp_proxy->username)
|
||||||
@ -897,5 +900,4 @@ uerr_t ftp_get_url_info_from_http_proxy(connection_t * connection)
|
|||||||
|
|
||||||
/* connection->file_type = REGULAR_FILE; */
|
/* connection->file_type = REGULAR_FILE; */
|
||||||
return FTPERR;
|
return FTPERR;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* HTTP support. */
|
/* HTTP support. */
|
||||||
|
|
||||||
/* $Id: http.h,v 1.12 2005/03/31 20:10:57 sean Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef HTTP_H
|
#ifndef HTTP_H
|
||||||
|
@ -41,7 +41,6 @@ int log_create_logfile(int num_connections, int file_size, char *url,
|
|||||||
download->u.file, DEFAULT_FILE_EXT);
|
download->u.file, DEFAULT_FILE_EXT);
|
||||||
if (!(fp = fopen(buffer, "wb")))
|
if (!(fp = fopen(buffer, "wb")))
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fixme add the error displaing to the main function
|
* fixme add the error displaing to the main function
|
||||||
*/
|
*/
|
||||||
@ -84,7 +83,6 @@ int log_create_logfile(int num_connections, int file_size, char *url,
|
|||||||
{
|
{
|
||||||
for (i = 0; i < download->num_connections; i++)
|
for (i = 0; i < download->num_connections; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_mutex_lock(&download->pconnections[i]->access_mutex);
|
pthread_mutex_lock(&download->pconnections[i]->access_mutex);
|
||||||
|
|
||||||
if (fwrite
|
if (fwrite
|
||||||
@ -92,7 +90,6 @@ int log_create_logfile(int num_connections, int file_size, char *url,
|
|||||||
sizeof(download->pconnections[i]->local_startpos),
|
sizeof(download->pconnections[i]->local_startpos),
|
||||||
fp) != sizeof(download->pconnections[i]->local_startpos))
|
fp) != sizeof(download->pconnections[i]->local_startpos))
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
||||||
download_show_message(download, _("Error writing to file %s: %s"),
|
download_show_message(download, _("Error writing to file %s: %s"),
|
||||||
buffer, strerror(errno));
|
buffer, strerror(errno));
|
||||||
@ -105,7 +102,6 @@ int log_create_logfile(int num_connections, int file_size, char *url,
|
|||||||
sizeof(download->pconnections[i]->orig_remote_startpos),
|
sizeof(download->pconnections[i]->orig_remote_startpos),
|
||||||
fp) != sizeof(download->pconnections[i]->orig_remote_startpos))
|
fp) != sizeof(download->pconnections[i]->orig_remote_startpos))
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
||||||
download_show_message(download, _("Error writing to file %s: %s"),
|
download_show_message(download, _("Error writing to file %s: %s"),
|
||||||
buffer, strerror(errno));
|
buffer, strerror(errno));
|
||||||
@ -130,7 +126,6 @@ int log_create_logfile(int num_connections, int file_size, char *url,
|
|||||||
sizeof(download->pconnections[i]->remote_bytes_received),
|
sizeof(download->pconnections[i]->remote_bytes_received),
|
||||||
fp) != sizeof(download->pconnections[i]->remote_bytes_received))
|
fp) != sizeof(download->pconnections[i]->remote_bytes_received))
|
||||||
{
|
{
|
||||||
|
|
||||||
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
||||||
download_show_message(download, _("Error writing to file %s: %s"),
|
download_show_message(download, _("Error writing to file %s: %s"),
|
||||||
buffer, strerror(errno));
|
buffer, strerror(errno));
|
||||||
@ -138,9 +133,7 @@ int log_create_logfile(int num_connections, int file_size, char *url,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
pthread_mutex_unlock(&download->pconnections[i]->access_mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@ -167,7 +160,8 @@ int proz_log_logfile_exists(download_t * download)
|
|||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +181,8 @@ int proz_log_delete_logfile(download_t * download)
|
|||||||
{
|
{
|
||||||
download_show_message(download, _("logfile doesn't exist"));
|
download_show_message(download, _("logfile doesn't exist"));
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
download_show_message(download, "Error: Unable to delete the logfile: %s", strerror(errno));
|
download_show_message(download, "Error: Unable to delete the logfile: %s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
@ -245,9 +240,6 @@ int proz_log_read_logfile(logfile * lf, download_t * download,
|
|||||||
{
|
{
|
||||||
for (i = 0; i < lf->num_connections; i++)
|
for (i = 0; i < lf->num_connections; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
proz_debug("value before= %d", download->pconnections[i]->local_startpos);
|
proz_debug("value before= %d", download->pconnections[i]->local_startpos);
|
||||||
|
|
||||||
if (fread
|
if (fread
|
||||||
@ -309,9 +301,7 @@ int proz_log_read_logfile(logfile * lf, download_t * download,
|
|||||||
}
|
}
|
||||||
|
|
||||||
proz_debug("remote_bytes_received after= %d", download->pconnections[i]->remote_bytes_received);
|
proz_debug("remote_bytes_received after= %d", download->pconnections[i]->remote_bytes_received);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,9 @@ int proz_init(int argc, char **argv)
|
|||||||
sprintf(netrc_file, "%s/%s", libprozrtinfo.home_dir, ".netrc");
|
sprintf(netrc_file, "%s/%s", libprozrtinfo.home_dir, ".netrc");
|
||||||
|
|
||||||
libprozrtinfo.netrc_list = parse_netrc(netrc_file);
|
libprozrtinfo.netrc_list = parse_netrc(netrc_file);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* Make sure home dir is never NULL */
|
/* Make sure home dir is never NULL */
|
||||||
libprozrtinfo.home_dir = kstrdup(".");
|
libprozrtinfo.home_dir = kstrdup(".");
|
||||||
}
|
}
|
||||||
@ -199,7 +201,6 @@ void proz_set_download_dir(char *dir)
|
|||||||
kfree(libprozrtinfo.dl_dir);
|
kfree(libprozrtinfo.dl_dir);
|
||||||
|
|
||||||
libprozrtinfo.dl_dir = kstrdup(dir);
|
libprozrtinfo.dl_dir = kstrdup(dir);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void proz_set_logfile_dir(char *dir)
|
void proz_set_logfile_dir(char *dir)
|
||||||
@ -224,6 +225,5 @@ void proz_set_output_dir(char *dir)
|
|||||||
|
|
||||||
char *proz_get_libprozilla_version()
|
char *proz_get_libprozilla_version()
|
||||||
{
|
{
|
||||||
|
|
||||||
return strdup(VERSION);
|
return strdup(VERSION);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Miscellaneous routines. */
|
/* Miscellaneous routines. */
|
||||||
|
|
||||||
/* $Id: misc.c,v 1.32 2005/01/11 01:49:11 sean Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -156,8 +156,7 @@ void prnum(char *where, long num)
|
|||||||
{
|
{
|
||||||
*p++ = num % 10 + '0';
|
*p++ = num % 10 + '0';
|
||||||
num /= 10;
|
num /= 10;
|
||||||
}
|
} while (num);
|
||||||
while (num);
|
|
||||||
|
|
||||||
/* And reverse them. */
|
/* And reverse them. */
|
||||||
l = p - where - 1;
|
l = p - where - 1;
|
||||||
@ -183,18 +182,20 @@ int setargval(char *optstr, int *num)
|
|||||||
{
|
{
|
||||||
*num = atoi(optstr + 1);
|
*num = atoi(optstr + 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (is_number(optstr))
|
if (is_number(optstr))
|
||||||
{
|
{
|
||||||
*num = atoi(optstr);
|
*num = atoi(optstr);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
@ -264,7 +265,6 @@ char *home_dir(void)
|
|||||||
int proz_timeval_subtract(struct timeval *result, struct timeval *x,
|
int proz_timeval_subtract(struct timeval *result, struct timeval *x,
|
||||||
struct timeval *y)
|
struct timeval *y)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Perform the carry for the later subtraction by updating Y. */
|
/* Perform the carry for the later subtraction by updating Y. */
|
||||||
if (x->tv_usec < y->tv_usec)
|
if (x->tv_usec < y->tv_usec)
|
||||||
{
|
{
|
||||||
@ -308,8 +308,8 @@ void delay_ms(int ms)
|
|||||||
/*Closes a socket and zeroes the socket before returning */
|
/*Closes a socket and zeroes the socket before returning */
|
||||||
int close_sock(int *sock)
|
int close_sock(int *sock)
|
||||||
{
|
{
|
||||||
|
|
||||||
int retval = close(*sock);
|
int retval = close(*sock);
|
||||||
|
|
||||||
*sock = 0;
|
*sock = 0;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -318,78 +318,109 @@ int close_sock(int *sock)
|
|||||||
|
|
||||||
char *proz_strerror(uerr_t error)
|
char *proz_strerror(uerr_t error)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (error)
|
switch (error)
|
||||||
{
|
{
|
||||||
|
|
||||||
case HOSTERR:
|
case HOSTERR:
|
||||||
return _("Unable to lookup hostname");
|
return _("Unable to lookup hostname");
|
||||||
|
|
||||||
case CONSOCKERR:
|
case CONSOCKERR:
|
||||||
return _("Unable to create socket");
|
return _("Unable to create socket");
|
||||||
|
|
||||||
case CONERROR:
|
case CONERROR:
|
||||||
return _("Error occured while connecting");
|
return _("Error occured while connecting");
|
||||||
|
|
||||||
case CONREFUSED:
|
case CONREFUSED:
|
||||||
return _("The connection attempt was refused");
|
return _("The connection attempt was refused");
|
||||||
|
|
||||||
case ACCEPTERR:
|
case ACCEPTERR:
|
||||||
return _("Error while accepting the connection");
|
return _("Error while accepting the connection");
|
||||||
|
|
||||||
case BINDERR:
|
case BINDERR:
|
||||||
return _("Error while Binding socket");
|
return _("Error while Binding socket");
|
||||||
|
|
||||||
case LISTENERR:
|
case LISTENERR:
|
||||||
return _("Error while listening");
|
return _("Error while listening");
|
||||||
|
|
||||||
case SERVERCLOSECONERR:
|
case SERVERCLOSECONERR:
|
||||||
return _("The connection was reset/closed by the peer");
|
return _("The connection was reset/closed by the peer");
|
||||||
|
|
||||||
case URLUNKNOWN:
|
case URLUNKNOWN:
|
||||||
return _("The URL Protocol was unknown");
|
return _("The URL Protocol was unknown");
|
||||||
|
|
||||||
case URLBADPORT:
|
case URLBADPORT:
|
||||||
return _("The port specified in the URL is not valid!");
|
return _("The port specified in the URL is not valid!");
|
||||||
|
|
||||||
case URLBADHOST:
|
case URLBADHOST:
|
||||||
return _("The Hostname specified in the URL is not valid!");
|
return _("The Hostname specified in the URL is not valid!");
|
||||||
|
|
||||||
case URLBADPATTERN:
|
case URLBADPATTERN:
|
||||||
return _("The Pattern specified in the URL does not look valid!");
|
return _("The Pattern specified in the URL does not look valid!");
|
||||||
|
|
||||||
case HEOF:
|
case HEOF:
|
||||||
return _("End of file reached in HTTP connection");
|
return _("End of file reached in HTTP connection");
|
||||||
|
|
||||||
case HERR:
|
case HERR:
|
||||||
return _("Error occured in HTTP data transfer");
|
return _("Error occured in HTTP data transfer");
|
||||||
|
|
||||||
case HAUTHREQ:
|
case HAUTHREQ:
|
||||||
return _("Authentification is required to access this resource");
|
return _("Authentification is required to access this resource");
|
||||||
|
|
||||||
case HAUTHFAIL:
|
case HAUTHFAIL:
|
||||||
return _("Failed to Authenticate with host!");
|
return _("Failed to Authenticate with host!");
|
||||||
|
|
||||||
case HTTPNSFOD:
|
case HTTPNSFOD:
|
||||||
return _("The URL was not found on the host!");
|
return _("The URL was not found on the host!");
|
||||||
|
|
||||||
case FTPLOGREFUSED:
|
case FTPLOGREFUSED:
|
||||||
return _("The host disallowed the login attempt");
|
return _("The host disallowed the login attempt");
|
||||||
|
|
||||||
case FTPPORTERR:
|
case FTPPORTERR:
|
||||||
return _("The PORT request was rejected by the server");
|
return _("The PORT request was rejected by the server");
|
||||||
|
|
||||||
case FTPNSFOD:
|
case FTPNSFOD:
|
||||||
return _("The object file/dir was not found on the host!");
|
return _("The object file/dir was not found on the host!");
|
||||||
|
|
||||||
case FTPUNKNOWNTYPE:
|
case FTPUNKNOWNTYPE:
|
||||||
return _("The TYPE specified in not known by the FTP server!");
|
return _("The TYPE specified in not known by the FTP server!");
|
||||||
|
|
||||||
case FTPUNKNOWNCMD:
|
case FTPUNKNOWNCMD:
|
||||||
return _("The command is not known by the FTP server!");
|
return _("The command is not known by the FTP server!");
|
||||||
|
|
||||||
case FTPSIZEFAIL:
|
case FTPSIZEFAIL:
|
||||||
return _("The SIZE command failed");
|
return _("The SIZE command failed");
|
||||||
|
|
||||||
case FTPERR:
|
case FTPERR:
|
||||||
return _("Error occured in FTP data transfer");
|
return _("Error occured in FTP data transfer");
|
||||||
|
|
||||||
case FTPRESTFAIL:
|
case FTPRESTFAIL:
|
||||||
return _("The REST command failed");
|
return _("The REST command failed");
|
||||||
|
|
||||||
case FTPACCDENIED:
|
case FTPACCDENIED:
|
||||||
return _("The peer did not allow access");
|
return _("The peer did not allow access");
|
||||||
|
|
||||||
case FTPPWDERR:
|
case FTPPWDERR:
|
||||||
return _("The host rejected the password");
|
return _("The host rejected the password");
|
||||||
|
|
||||||
case FTPPWDFAIL:
|
case FTPPWDFAIL:
|
||||||
return _("The host rejected the password");
|
return _("The host rejected the password");
|
||||||
|
|
||||||
case FTPINVPASV:
|
case FTPINVPASV:
|
||||||
return _("The PASV (passive mode) was not supported the host");
|
return _("The PASV (passive mode) was not supported the host");
|
||||||
|
|
||||||
case FTPNOPASV:
|
case FTPNOPASV:
|
||||||
return _("The host does not support PASV (passive mode) transfers");
|
return _("The host does not support PASV (passive mode) transfers");
|
||||||
|
|
||||||
case FTPCONREFUSED:
|
case FTPCONREFUSED:
|
||||||
return _("The connection attempt was refused");
|
return _("The connection attempt was refused");
|
||||||
|
|
||||||
case FTPCWDFAIL:
|
case FTPCWDFAIL:
|
||||||
return _("Failed to (CWD)change to the directory");
|
return _("Failed to (CWD)change to the directory");
|
||||||
|
|
||||||
case FTPSERVCLOSEDATLOGIN:
|
case FTPSERVCLOSEDATLOGIN:
|
||||||
return
|
return
|
||||||
_
|
_
|
||||||
("The host said the requested service was unavailable and closed the control connection");
|
("The host said the requested service was unavailable and closed the control connection");
|
||||||
|
|
||||||
case CONPORTERR:
|
case CONPORTERR:
|
||||||
return _("getsockname failed!");
|
return _("getsockname failed!");
|
||||||
|
|
||||||
@ -420,28 +451,34 @@ char *proz_strerror(uerr_t error)
|
|||||||
|
|
||||||
case FOPENERR:
|
case FOPENERR:
|
||||||
return _("Error while opening file");
|
return _("Error while opening file");
|
||||||
|
|
||||||
case FWRITEERR:
|
case FWRITEERR:
|
||||||
return _("Error while writing to file");
|
return _("Error while writing to file");
|
||||||
|
|
||||||
case DLABORTED:
|
case DLABORTED:
|
||||||
return _("The Download was aborted");
|
return _("The Download was aborted");
|
||||||
|
|
||||||
case DLLOCALFATAL:
|
case DLLOCALFATAL:
|
||||||
return _("The Download encountered a local fatal error");
|
return _("The Download encountered a local fatal error");
|
||||||
|
|
||||||
case CANTRESUME:
|
case CANTRESUME:
|
||||||
return _("Error: Resuming this connection is not possible");
|
return _("Error: Resuming this connection is not possible");
|
||||||
|
|
||||||
case READERR:
|
case READERR:
|
||||||
return _("Error while reading data from socket");
|
return _("Error while reading data from socket");
|
||||||
|
|
||||||
case WRITEERR:
|
case WRITEERR:
|
||||||
return _("Error while writing data to socket");
|
return _("Error while writing data to socket");
|
||||||
|
|
||||||
case PROXERR:
|
case PROXERR:
|
||||||
return _("Error while Proxying");
|
return _("Error while Proxying");
|
||||||
|
|
||||||
case FILEISDIR:
|
case FILEISDIR:
|
||||||
return _("The location is a directory");
|
return _("The location is a directory");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return _("Unknown/Unsupported error code");
|
return _("Unknown/Unsupported error code");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cleanup handler which will be popped and which will be called when the thread is cancelled, it make sure that there will be no sockets left open if the thread is cancelled prematurely
|
/* Cleanup handler which will be popped and which will be called when the thread is cancelled, it make sure that there will be no sockets left open if the thread is cancelled prematurely
|
||||||
@ -457,6 +494,7 @@ void cleanup_socks(void *cdata)
|
|||||||
case URLHTTP:
|
case URLHTTP:
|
||||||
cleanup_httpsocks(connection);
|
cleanup_httpsocks(connection);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case URLFTP:
|
case URLFTP:
|
||||||
if (ftp_use_proxy(connection)
|
if (ftp_use_proxy(connection)
|
||||||
&& connection->ftp_proxy->type == HTTPPROXY)
|
&& connection->ftp_proxy->type == HTTPPROXY)
|
||||||
@ -464,9 +502,11 @@ void cleanup_socks(void *cdata)
|
|||||||
/* We have to cleanup the http socks instead
|
/* We have to cleanup the http socks instead
|
||||||
if we are going through a http proxy */
|
if we are going through a http proxy */
|
||||||
cleanup_httpsocks(connection);
|
cleanup_httpsocks(connection);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
cleanup_ftpsocks(connection);
|
cleanup_ftpsocks(connection);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
proz_die(_("Error: unsupported protocol"));
|
proz_die(_("Error: unsupported protocol"));
|
||||||
}
|
}
|
||||||
@ -487,7 +527,8 @@ void cleanup_ftpsocks(connection_t * connection)
|
|||||||
if (flags == -1)
|
if (flags == -1)
|
||||||
{
|
{
|
||||||
proz_debug("data sock invalid\n");
|
proz_debug("data sock invalid\n");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
close_sock(&connection->data_sock);
|
close_sock(&connection->data_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,10 +538,10 @@ void cleanup_ftpsocks(connection_t * connection)
|
|||||||
if (flags == -1)
|
if (flags == -1)
|
||||||
{
|
{
|
||||||
proz_debug("control sock invalid\n");
|
proz_debug("control sock invalid\n");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
close_sock(&connection->ctrl_sock);
|
close_sock(&connection->ctrl_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -516,10 +557,10 @@ void cleanup_httpsocks(connection_t * connection)
|
|||||||
if (flags == -1)
|
if (flags == -1)
|
||||||
{
|
{
|
||||||
proz_debug("sock invalid\n");
|
proz_debug("sock invalid\n");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
close(connection->data_sock);
|
close(connection->data_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Miscellaneous routines. */
|
/* Miscellaneous routines. */
|
||||||
|
|
||||||
/* $Id: misc.h,v 1.25 2001/09/02 23:29:16 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef MISC_H
|
#ifndef MISC_H
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
/* Slightly modified for libprozilla, by Grendel <kalum@delrom.ro>. */
|
/* Slightly modified for libprozilla, by Grendel <kalum@delrom.ro>. */
|
||||||
|
|
||||||
/* $Id: netrc.c,v 1.17 2001/08/09 23:35:26 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -35,6 +35,7 @@
|
|||||||
static void maybe_add_to_list(netrc_entry ** newentry, netrc_entry ** list)
|
static void maybe_add_to_list(netrc_entry ** newentry, netrc_entry ** list)
|
||||||
{
|
{
|
||||||
netrc_entry *a, *l;
|
netrc_entry *a, *l;
|
||||||
|
|
||||||
a = *newentry;
|
a = *newentry;
|
||||||
l = *list;
|
l = *list;
|
||||||
|
|
||||||
@ -46,7 +47,8 @@ static void maybe_add_to_list(netrc_entry ** newentry, netrc_entry ** list)
|
|||||||
kfree(a->host);
|
kfree(a->host);
|
||||||
if (a->password)
|
if (a->password)
|
||||||
kfree(a->password);
|
kfree(a->password);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (a)
|
if (a)
|
||||||
{
|
{
|
||||||
@ -146,13 +148,15 @@ netrc_entry *parse_netrc(char *file)
|
|||||||
{
|
{
|
||||||
quote_char = 0;
|
quote_char = 0;
|
||||||
p++;
|
p++;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
*pp = *p;
|
*pp = *p;
|
||||||
p++;
|
p++;
|
||||||
pp++;
|
pp++;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (*p == '"' || *p == '\'')
|
if (*p == '"' || *p == '\'')
|
||||||
quote_char = *p;
|
quote_char = *p;
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
/* $Id: netrc.h,v 1.11 2001/05/30 15:01:40 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef NETRC_H
|
#ifndef NETRC_H
|
||||||
|
@ -52,7 +52,8 @@ uerr_t tcp_ping(ping_t * ping_data)
|
|||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
error = getaddrinfo(ping_data->host, szPort, &hints, &res);
|
error = getaddrinfo(ping_data->host, szPort, &hints, &res);
|
||||||
if (error) {
|
if (error)
|
||||||
|
{
|
||||||
return ping_data->err = HOSTERR;
|
return ping_data->err = HOSTERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +102,8 @@ uerr_t tcp_ping(ping_t * ping_data)
|
|||||||
|
|
||||||
if (errno == EINPROGRESS)
|
if (errno == EINPROGRESS)
|
||||||
errno = ETIMEDOUT;
|
errno = ETIMEDOUT;
|
||||||
} else if (status == 0)
|
}
|
||||||
|
else if (status == 0)
|
||||||
errno = ETIMEDOUT, status = -1;
|
errno = ETIMEDOUT, status = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,16 +115,19 @@ uerr_t tcp_ping(ping_t * ping_data)
|
|||||||
{
|
{
|
||||||
free(res);
|
free(res);
|
||||||
return ping_data->err = CONREFUSED;
|
return ping_data->err = CONREFUSED;
|
||||||
} else if (errno == ETIMEDOUT)
|
}
|
||||||
|
else if (errno == ETIMEDOUT)
|
||||||
{
|
{
|
||||||
free(res);
|
free(res);
|
||||||
return ping_data->err = PINGTIMEOUT;
|
return ping_data->err = PINGTIMEOUT;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
free(res);
|
free(res);
|
||||||
return ping_data->err = CONERROR;
|
return ping_data->err = CONERROR;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
flags = fcntl(ping_data->sock, F_GETFL, 0);
|
flags = fcntl(ping_data->sock, F_GETFL, 0);
|
||||||
|
|
||||||
@ -172,12 +177,10 @@ uerr_t tcp_ping(ping_t * ping_data)
|
|||||||
|
|
||||||
void proz_mass_ping(ftps_request_t * request)
|
void proz_mass_ping(ftps_request_t * request)
|
||||||
{
|
{
|
||||||
|
|
||||||
request->mass_ping_running = TRUE;
|
request->mass_ping_running = TRUE;
|
||||||
if (pthread_create(&request->mass_ping_thread, NULL,
|
if (pthread_create(&request->mass_ping_thread, NULL,
|
||||||
(void *)&mass_ping, (void *)request) != 0)
|
(void *)&mass_ping, (void *)request) != 0)
|
||||||
proz_die(_("Error: Not enough system resources"));
|
proz_die(_("Error: Not enough system resources"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void proz_cancel_mass_ping(ftps_request_t * request)
|
void proz_cancel_mass_ping(ftps_request_t * request)
|
||||||
@ -248,7 +251,8 @@ void mass_ping(ftps_request_t * request)
|
|||||||
(ping_requests[k].ping_time.tv_usec / 1000);
|
(ping_requests[k].ping_time.tv_usec / 1000);
|
||||||
request->mirrors[k].status = RESPONSEOK;
|
request->mirrors[k].status = RESPONSEOK;
|
||||||
pthread_mutex_unlock(&request->access_mutex);
|
pthread_mutex_unlock(&request->access_mutex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&request->access_mutex);
|
pthread_mutex_lock(&request->access_mutex);
|
||||||
request->mirrors[k].status = NORESPONSE;
|
request->mirrors[k].status = NORESPONSE;
|
||||||
@ -295,7 +299,8 @@ void mass_ping(ftps_request_t * request)
|
|||||||
(ping_requests[k].ping_time.tv_usec / 1000);
|
(ping_requests[k].ping_time.tv_usec / 1000);
|
||||||
request->mirrors[k].status = RESPONSEOK;
|
request->mirrors[k].status = RESPONSEOK;
|
||||||
pthread_mutex_unlock(&request->access_mutex);
|
pthread_mutex_unlock(&request->access_mutex);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&request->access_mutex);
|
pthread_mutex_lock(&request->access_mutex);
|
||||||
request->mirrors[k].status = NORESPONSE;
|
request->mirrors[k].status = NORESPONSE;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* Main include-file. */
|
/* Main include-file. */
|
||||||
|
|
||||||
/* $Id: prozilla.h,v 1.63 2005/09/19 15:25:48 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef PROZILLA_H
|
#ifndef PROZILLA_H
|
||||||
@ -223,7 +223,6 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct connection_t {
|
typedef struct connection_t {
|
||||||
|
|
||||||
/* struct which contains the parsed url info. It includes the remote file,
|
/* struct which contains the parsed url info. It includes the remote file,
|
||||||
path,protocol etc. */
|
path,protocol etc. */
|
||||||
urlinfo u;
|
urlinfo u;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
/* A test program. */
|
/* A test program. */
|
||||||
|
|
||||||
/* $Id: test.c,v 1.30 2001/09/23 01:39:16 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
/* $Id: url.c,v 1.23 2001/10/27 11:24:40 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -181,6 +181,7 @@ int skip_uname(const char *url)
|
|||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
const char *q = NULL;
|
const char *q = NULL;
|
||||||
|
|
||||||
for (p = url; *p && *p != '/'; p++)
|
for (p = url; *p && *p != '/'; p++)
|
||||||
if (*p == '@')
|
if (*p == '@')
|
||||||
q = p;
|
q = p;
|
||||||
@ -210,7 +211,8 @@ void decode_string(char *s)
|
|||||||
{
|
{
|
||||||
copychar:
|
copychar:
|
||||||
*t = *h;
|
*t = *h;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* Do nothing if '%' is not followed by two hex digits. */
|
/* Do nothing if '%' is not followed by two hex digits. */
|
||||||
if (!*(h + 1) || !*(h + 2)
|
if (!*(h + 1) || !*(h + 2)
|
||||||
@ -231,12 +233,14 @@ char *encode_string_maybe(const char *s)
|
|||||||
char *p2, *newstr;
|
char *p2, *newstr;
|
||||||
int newlen;
|
int newlen;
|
||||||
int addition = 0;
|
int addition = 0;
|
||||||
|
|
||||||
/*Changes Grendel: (*p1!='%') added */
|
/*Changes Grendel: (*p1!='%') added */
|
||||||
|
|
||||||
|
|
||||||
for (p1 = s; *p1; p1++)
|
for (p1 = s; *p1; p1++)
|
||||||
if ((*p1 != '%') && UNSAFE_CHAR(*p1))
|
if ((*p1 != '%') && UNSAFE_CHAR(*p1))
|
||||||
addition += 2; /* Two more characters (hex digits) */
|
addition += 2;
|
||||||
|
/* Two more characters (hex digits) */
|
||||||
|
|
||||||
if (!addition)
|
if (!addition)
|
||||||
return (char *)s;
|
return (char *)s;
|
||||||
@ -256,7 +260,8 @@ if ((*p1!='%') && UNSAFE_CHAR(*p1))
|
|||||||
*p2++ = '%';
|
*p2++ = '%';
|
||||||
*p2++ = XDIGIT_TO_XCHAR(c >> 4);
|
*p2++ = XDIGIT_TO_XCHAR(c >> 4);
|
||||||
*p2++ = XDIGIT_TO_XCHAR(c & 0xf);
|
*p2++ = XDIGIT_TO_XCHAR(c & 0xf);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
*p2++ = *p1++;
|
*p2++ = *p1++;
|
||||||
}
|
}
|
||||||
*p2 = '\0';
|
*p2 = '\0';
|
||||||
@ -290,7 +295,7 @@ char *encode_string(const char *s)
|
|||||||
ptr = e_new; \
|
ptr = e_new; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Returns the protocol type if URL's protocol is supported, or
|
/* Returns the protocol type if URL's protocol is supported, or
|
||||||
URLUNKNOWN if not. */
|
URLUNKNOWN if not. */
|
||||||
uerr_t urlproto(const char *url)
|
uerr_t urlproto(const char *url)
|
||||||
@ -300,7 +305,8 @@ uerr_t urlproto(const char *url)
|
|||||||
for (i = 0; i < ARRAY_SIZE(sup_protos); i++)
|
for (i = 0; i < ARRAY_SIZE(sup_protos); i++)
|
||||||
if (!strncasecmp(url, sup_protos[i].name, strlen(sup_protos[i].name)))
|
if (!strncasecmp(url, sup_protos[i].name, strlen(sup_protos[i].name)))
|
||||||
return sup_protos[i].ind;
|
return sup_protos[i].ind;
|
||||||
for (i = 0; url[i] && url[i] != ':' && url[i] != '/'; i++);
|
for (i = 0; url[i] && url[i] != ':' && url[i] != '/'; i++)
|
||||||
|
;
|
||||||
if (url[i] == ':')
|
if (url[i] == ':')
|
||||||
{
|
{
|
||||||
for (++i; url[i] && url[i] != '/'; i++)
|
for (++i; url[i] && url[i] != '/'; i++)
|
||||||
@ -310,7 +316,8 @@ uerr_t urlproto(const char *url)
|
|||||||
return URLFTP;
|
return URLFTP;
|
||||||
else
|
else
|
||||||
return URLHTTP;
|
return URLHTTP;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return URLHTTP;
|
return URLHTTP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +331,8 @@ char process_ftp_type(char *path)
|
|||||||
{
|
{
|
||||||
path[len - 7] = '\0';
|
path[len - 7] = '\0';
|
||||||
return path[len - 1];
|
return path[len - 1];
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +375,8 @@ void path_simplify(char *path)
|
|||||||
{
|
{
|
||||||
i += 3;
|
i += 3;
|
||||||
ddot = 1;
|
ddot = 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i)
|
if (i)
|
||||||
@ -433,7 +442,8 @@ void path_simplify(char *path)
|
|||||||
/* Handle `../' or trailing `..' by itself. */
|
/* Handle `../' or trailing `..' by itself. */
|
||||||
if (path[i + 1] == '.' && (path[i + 2] == '/' || !path[i + 2]))
|
if (path[i + 1] == '.' && (path[i + 2] == '/' || !path[i + 2]))
|
||||||
{
|
{
|
||||||
while (--start > -1 && path[start] != '/');
|
while (--start > -1 && path[start] != '/')
|
||||||
|
;
|
||||||
strcpy(path + start + 1, path + i + 2);
|
strcpy(path + start + 1, path + i + 2);
|
||||||
i = (start < 0) ? 0 : start;
|
i = (start < 0) ? 0 : start;
|
||||||
continue;
|
continue;
|
||||||
@ -461,6 +471,7 @@ void path_simplify(char *path)
|
|||||||
int urlpath_length(const char *url)
|
int urlpath_length(const char *url)
|
||||||
{
|
{
|
||||||
const char *q = strchr(url, '?');
|
const char *q = strchr(url, '?');
|
||||||
|
|
||||||
if (q)
|
if (q)
|
||||||
return q - url;
|
return q - url;
|
||||||
return strlen(url);
|
return strlen(url);
|
||||||
@ -477,7 +488,8 @@ void parse_dir(const char *path, char **dir, char **file)
|
|||||||
int i, l;
|
int i, l;
|
||||||
|
|
||||||
l = urlpath_length(path);
|
l = urlpath_length(path);
|
||||||
for (i = l; i && path[i] != '/'; i--);
|
for (i = l; i && path[i] != '/'; i--)
|
||||||
|
;
|
||||||
|
|
||||||
if (!i && *path != '/') /* Just filename */
|
if (!i && *path != '/') /* Just filename */
|
||||||
{
|
{
|
||||||
@ -486,31 +498,36 @@ void parse_dir(const char *path, char **dir, char **file)
|
|||||||
*dir = strdupdelim(path, path + l);
|
*dir = strdupdelim(path, path + l);
|
||||||
*file = kstrdup(path + l); /* normally empty, but could
|
*file = kstrdup(path + l); /* normally empty, but could
|
||||||
contain ?... */
|
contain ?... */
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
*dir = kstrdup(""); /* This is required because of FTP */
|
*dir = kstrdup(""); /* This is required because of FTP */
|
||||||
*file = kstrdup(path);
|
*file = kstrdup(path);
|
||||||
}
|
}
|
||||||
} else if (!i) /* /filename */
|
}
|
||||||
|
else if (!i) /* /filename */
|
||||||
{
|
{
|
||||||
if (PD_DOTP(path + 1) || PD_DDOTP(path + 1))
|
if (PD_DOTP(path + 1) || PD_DDOTP(path + 1))
|
||||||
{
|
{
|
||||||
*dir = strdupdelim(path, path + l);
|
*dir = strdupdelim(path, path + l);
|
||||||
*file = kstrdup(path + l); /* normally empty, but could
|
*file = kstrdup(path + l); /* normally empty, but could
|
||||||
contain ?... */
|
contain ?... */
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
*dir = kstrdup("/");
|
*dir = kstrdup("/");
|
||||||
*file = kstrdup(path + 1);
|
*file = kstrdup(path + 1);
|
||||||
}
|
}
|
||||||
} else /* Nonempty directory with or without a filename */
|
}
|
||||||
|
else /* Nonempty directory with or without a filename */
|
||||||
{
|
{
|
||||||
if (PD_DOTP(path + i + 1) || PD_DDOTP(path + i + 1))
|
if (PD_DOTP(path + i + 1) || PD_DDOTP(path + i + 1))
|
||||||
{
|
{
|
||||||
*dir = strdupdelim(path, path + l);
|
*dir = strdupdelim(path, path + l);
|
||||||
*file = kstrdup(path + l); /* normally empty, but could
|
*file = kstrdup(path + l); /* normally empty, but could
|
||||||
contain ?... */
|
contain ?... */
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
*dir = strdupdelim(path, path + i);
|
*dir = strdupdelim(path, path + i);
|
||||||
*file = kstrdup(path + i + 1);
|
*file = kstrdup(path + i + 1);
|
||||||
@ -735,7 +752,8 @@ uerr_t proz_parse_url(const char *url, urlinfo * u, int strict)
|
|||||||
them for now). */
|
them for now). */
|
||||||
if (recognizable)
|
if (recognizable)
|
||||||
l += skip_uname(url + l);
|
l += skip_uname(url + l);
|
||||||
for (i = l; url[i] && url[i] != ':' && url[i] != '/'; i++);
|
for (i = l; url[i] && url[i] != ':' && url[i] != '/'; i++)
|
||||||
|
;
|
||||||
if (i == l)
|
if (i == l)
|
||||||
return URLBADHOST;
|
return URLBADHOST;
|
||||||
/* Get the hostname. */
|
/* Get the hostname. */
|
||||||
@ -758,11 +776,13 @@ uerr_t proz_parse_url(const char *url, urlinfo * u, int strict)
|
|||||||
return URLBADPORT;
|
return URLBADPORT;
|
||||||
if (!u->port)
|
if (!u->port)
|
||||||
return URLBADPORT;
|
return URLBADPORT;
|
||||||
} else if (type == URLUNKNOWN) /* or a directory */
|
}
|
||||||
|
else if (type == URLUNKNOWN) /* or a directory */
|
||||||
u->proto = type = URLFTP;
|
u->proto = type = URLFTP;
|
||||||
else /* or just a misformed port number */
|
else /* or just a misformed port number */
|
||||||
return URLBADPORT;
|
return URLBADPORT;
|
||||||
} else if (type == URLUNKNOWN)
|
}
|
||||||
|
else if (type == URLUNKNOWN)
|
||||||
u->proto = type = URLHTTP;
|
u->proto = type = URLHTTP;
|
||||||
if (!u->port)
|
if (!u->port)
|
||||||
{
|
{
|
||||||
@ -868,7 +888,8 @@ char *construct_relative(const char *s1, const char *s2)
|
|||||||
{
|
{
|
||||||
for (;
|
for (;
|
||||||
s1[i] && s2[i] && s1[i] == s2[i] && s1[i] != '/'
|
s1[i] && s2[i] && s1[i] == s2[i] && s1[i] != '/'
|
||||||
&& s2[i] != '/'; i++);
|
&& s2[i] != '/'; i++)
|
||||||
|
;
|
||||||
if (s1[i] == '/' && s2[i] == '/')
|
if (s1[i] == '/' && s2[i] == '/')
|
||||||
cnt = ++i;
|
cnt = ++i;
|
||||||
else
|
else
|
||||||
@ -913,8 +934,6 @@ urlpos *add_url(urlpos * l, const char *url, const char *file)
|
|||||||
/*This will copy a url structure to another */
|
/*This will copy a url structure to another */
|
||||||
void url_cpy(urlinfo * src, urlinfo * dest)
|
void url_cpy(urlinfo * src, urlinfo * dest)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -983,14 +1002,16 @@ char *uri_merge_1(const char *base, const char *link, int linklength,
|
|||||||
/* ^ ('?' gets changed to '/') */
|
/* ^ ('?' gets changed to '/') */
|
||||||
start_insert = end + 1;
|
start_insert = end + 1;
|
||||||
need_explicit_slash = 1;
|
need_explicit_slash = 1;
|
||||||
} else if (last_slash && last_slash != base
|
}
|
||||||
|
else if (last_slash && last_slash != base
|
||||||
&& *(last_slash - 1) == '/')
|
&& *(last_slash - 1) == '/')
|
||||||
{
|
{
|
||||||
/* example: http://host" */
|
/* example: http://host" */
|
||||||
/* ^ */
|
/* ^ */
|
||||||
start_insert = end + 1;
|
start_insert = end + 1;
|
||||||
need_explicit_slash = 1;
|
need_explicit_slash = 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/* example: "whatever/foo/bar" */
|
/* example: "whatever/foo/bar" */
|
||||||
/* ^ */
|
/* ^ */
|
||||||
@ -1006,7 +1027,8 @@ char *uri_merge_1(const char *base, const char *link, int linklength,
|
|||||||
if (linklength)
|
if (linklength)
|
||||||
memcpy(constr + span, link, linklength);
|
memcpy(constr + span, link, linklength);
|
||||||
constr[span + linklength] = '\0';
|
constr[span + linklength] = '\0';
|
||||||
} else /* *link == `/' */
|
}
|
||||||
|
else /* *link == `/' */
|
||||||
{
|
{
|
||||||
/* LINK is an absolute path: we need to replace everything
|
/* LINK is an absolute path: we need to replace everything
|
||||||
after (and including) the FIRST slash with LINK.
|
after (and including) the FIRST slash with LINK.
|
||||||
@ -1062,7 +1084,8 @@ char *uri_merge_1(const char *base, const char *link, int linklength,
|
|||||||
memcpy(constr + span, link, linklength);
|
memcpy(constr + span, link, linklength);
|
||||||
constr[span + linklength] = '\0';
|
constr[span + linklength] = '\0';
|
||||||
}
|
}
|
||||||
} else /* !no_proto */
|
}
|
||||||
|
else /* !no_proto */
|
||||||
{
|
{
|
||||||
constr = strdupdelim(link, link + linklength);
|
constr = strdupdelim(link, link + linklength);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
/* $Id: url.h,v 1.20 2001/08/17 21:53:39 kalum Exp $ */
|
/* $Id$ */
|
||||||
|
|
||||||
|
|
||||||
#ifndef URL_H
|
#ifndef URL_H
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
fltk prozilla - a front end for prozilla, a download accelerator library
|
* fltk prozilla - a front end for prozilla, a download accelerator library
|
||||||
Copyright (C) 2001 Kalum Somaratna
|
* Copyright (C) 2001 Kalum Somaratna
|
||||||
|
*
|
||||||
This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
(at your option) any later version.
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
@ -38,7 +38,6 @@
|
|||||||
void
|
void
|
||||||
DL_Window::cleanup(boolean erase_dlparts)
|
DL_Window::cleanup(boolean erase_dlparts)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*handle cleanup */
|
/*handle cleanup */
|
||||||
if (status == DL_DOWNLOADING)
|
if (status == DL_DOWNLOADING)
|
||||||
{
|
{
|
||||||
@ -69,13 +68,14 @@ DL_Window::cleanup (boolean erase_dlparts)
|
|||||||
status = DL_ABORTED;
|
status = DL_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DL_Window::~DL_Window()
|
DL_Window::~DL_Window()
|
||||||
{
|
{
|
||||||
proz_connection_free_connection(connection, true);
|
proz_connection_free_connection(connection, true);
|
||||||
delete (ftpsearch_win);
|
delete (ftpsearch_win);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DL_Window::DL_Window(urlinfo *url_data)
|
DL_Window::DL_Window(urlinfo *url_data)
|
||||||
{
|
{
|
||||||
// key = 0;
|
// key = 0;
|
||||||
@ -90,9 +90,9 @@ DL_Window::DL_Window (urlinfo * url_data)
|
|||||||
ftpsearch_win = new FTPS_Window();
|
ftpsearch_win = new FTPS_Window();
|
||||||
do_ftpsearch = FALSE;
|
do_ftpsearch = FALSE;
|
||||||
using_ftpsearch = FALSE;
|
using_ftpsearch = FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::my_cb()
|
DL_Window::my_cb()
|
||||||
{
|
{
|
||||||
@ -104,8 +104,8 @@ DL_Window::my_cb ()
|
|||||||
|
|
||||||
|
|
||||||
// if ((got_info == TRUE && status == DL_IDLING && got_dl == FALSE)
|
// if ((got_info == TRUE && status == DL_IDLING && got_dl == FALSE)
|
||||||
if ((status == DL_RESTARTING && got_info == TRUE)
|
if (((status == DL_RESTARTING) && (got_info == TRUE)) ||
|
||||||
|| status == DL_DLPRESTART)
|
(status == DL_DLPRESTART))
|
||||||
{
|
{
|
||||||
do_download();
|
do_download();
|
||||||
}
|
}
|
||||||
@ -139,15 +139,12 @@ DL_Window::my_cb ()
|
|||||||
handle_ftpsearch();
|
handle_ftpsearch();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::dl_start(int num_connections, boolean ftpsearch)
|
DL_Window::dl_start(int num_connections, boolean ftpsearch)
|
||||||
{
|
{
|
||||||
|
|
||||||
do_ftpsearch = ftpsearch;
|
do_ftpsearch = ftpsearch;
|
||||||
|
|
||||||
connection = proz_connection_init(&u, &getinfo_mutex);
|
connection = proz_connection_init(&u, &getinfo_mutex);
|
||||||
@ -164,6 +161,7 @@ void
|
|||||||
DL_Window::do_download()
|
DL_Window::do_download()
|
||||||
{
|
{
|
||||||
logfile lf;
|
logfile lf;
|
||||||
|
|
||||||
status = DL_DLPRESTART;
|
status = DL_DLPRESTART;
|
||||||
//setup the download
|
//setup the download
|
||||||
download = proz_download_init(&connection->u);
|
download = proz_download_init(&connection->u);
|
||||||
@ -193,18 +191,22 @@ DL_Window::do_download ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rt.display_mode == DISP_CURSES)
|
if (rt.display_mode == DISP_CURSES)
|
||||||
|
{
|
||||||
erase();
|
erase();
|
||||||
|
}
|
||||||
|
|
||||||
start_download();
|
start_download();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::handle_prev_download()
|
DL_Window::handle_prev_download()
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* we will check and see if 1. previous partial download exists and
|
/* we will check and see if 1. previous partial download exists and
|
||||||
2. if the file to be downloaded already exists in the local
|
* 2. if the file to be downloaded already exists in the local
|
||||||
directory
|
* directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Check and see if the file is already downloaded..
|
//Check and see if the file is already downloaded..
|
||||||
@ -224,14 +226,12 @@ DL_Window::handle_prev_download ()
|
|||||||
status = DL_FATALERR;
|
status = DL_FATALERR;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Check for a prior download */
|
/*Check for a prior download */
|
||||||
int previous_dl = proz_download_prev_download_exists(download);
|
int previous_dl = proz_download_prev_download_exists(download);
|
||||||
if (previous_dl == 1)
|
if (previous_dl == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
download->resume_mode = TRUE;
|
download->resume_mode = TRUE;
|
||||||
//connection supports resume
|
//connection supports resume
|
||||||
if (connection->resume_support)
|
if (connection->resume_support)
|
||||||
@ -241,25 +241,33 @@ DL_Window::handle_prev_download ()
|
|||||||
{
|
{
|
||||||
//see if the user had a preference, resume or overwrite
|
//see if the user had a preference, resume or overwrite
|
||||||
if (rt.resume_mode == TRUE)
|
if (rt.resume_mode == TRUE)
|
||||||
|
{
|
||||||
download->resume_mode = TRUE;
|
download->resume_mode = TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if (rt.force_mode == TRUE)
|
if (rt.force_mode == TRUE)
|
||||||
|
{
|
||||||
download->resume_mode = FALSE;
|
download->resume_mode = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//ask the user (curses or terminal)
|
//ask the user (curses or terminal)
|
||||||
ret = askUserResume(connection, true);
|
ret = askUserResume(connection, true);
|
||||||
if (ret == 'R')
|
if (ret == 'R')
|
||||||
|
{
|
||||||
download->resume_mode = TRUE;
|
download->resume_mode = TRUE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
download->resume_mode = FALSE;
|
download->resume_mode = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ //resume NOT supported
|
{ //resume NOT supported
|
||||||
// --no-getch and no force-mode means fatal error!!!
|
// --no-getch and no force-mode means fatal error!!!
|
||||||
if (rt.dont_prompt == TRUE && rt.force_mode == FALSE)
|
if ((rt.dont_prompt == TRUE) && (rt.force_mode == FALSE))
|
||||||
{
|
{
|
||||||
status = DL_FATALERR;
|
status = DL_FATALERR;
|
||||||
handle_dl_fatal_error();
|
handle_dl_fatal_error();
|
||||||
@ -267,14 +275,18 @@ DL_Window::handle_prev_download ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//force overwrite
|
//force overwrite
|
||||||
if (rt.dont_prompt == TRUE && rt.force_mode == TRUE)
|
if ((rt.dont_prompt == TRUE) && (rt.force_mode == TRUE))
|
||||||
|
{
|
||||||
download->resume_mode = FALSE;
|
download->resume_mode = FALSE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Ask the user
|
//Ask the user
|
||||||
ret = askUserResume(connection, false);
|
ret = askUserResume(connection, false);
|
||||||
if (ret == 'O')
|
if (ret == 'O')
|
||||||
|
{
|
||||||
download->resume_mode = FALSE;
|
download->resume_mode = FALSE;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{ //Abort
|
{ //Abort
|
||||||
status = DL_FATALERR;
|
status = DL_FATALERR;
|
||||||
@ -287,7 +299,6 @@ DL_Window::handle_prev_download ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::start_download()
|
DL_Window::start_download()
|
||||||
{
|
{
|
||||||
@ -295,15 +306,19 @@ DL_Window::start_download ()
|
|||||||
|
|
||||||
proz_debug("start_download");
|
proz_debug("start_download");
|
||||||
if (using_ftpsearch != TRUE)
|
if (using_ftpsearch != TRUE)
|
||||||
|
{
|
||||||
ret = num_connections =
|
ret = num_connections =
|
||||||
proz_download_setup_connections_no_ftpsearch
|
proz_download_setup_connections_no_ftpsearch
|
||||||
(download, connection, num_connections);
|
(download, connection, num_connections);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ret = proz_download_setup_connections_ftpsearch(download,
|
ret = proz_download_setup_connections_ftpsearch(download,
|
||||||
connection,
|
connection,
|
||||||
ftpsearch_win->
|
ftpsearch_win->
|
||||||
request,
|
request,
|
||||||
num_connections);
|
num_connections);
|
||||||
|
}
|
||||||
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
@ -326,10 +341,9 @@ DL_Window::start_download ()
|
|||||||
|
|
||||||
proz_download_start_downloads(download, download->resume_mode);
|
proz_download_start_downloads(download, download->resume_mode);
|
||||||
status = DL_DOWNLOADING;
|
status = DL_DOWNLOADING;
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::handle_info_thread()
|
DL_Window::handle_info_thread()
|
||||||
{
|
{
|
||||||
@ -340,7 +354,7 @@ DL_Window::handle_info_thread ()
|
|||||||
{
|
{
|
||||||
pthread_join(info_thread, NULL);
|
pthread_join(info_thread, NULL);
|
||||||
|
|
||||||
if (connection->err == HOK || connection->err == FTPOK)
|
if ((connection->err == HOK) || (connection->err == FTPOK))
|
||||||
{
|
{
|
||||||
got_info = TRUE;
|
got_info = TRUE;
|
||||||
|
|
||||||
@ -350,11 +364,13 @@ DL_Window::handle_info_thread ()
|
|||||||
connection->main_file_size / 1024);
|
connection->main_file_size / 1024);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
PrintMessage("File Size is UNKOWN\n\n");
|
PrintMessage("File Size is UNKOWN\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
//Added ftpsearch only is size > min size
|
//Added ftpsearch only is size > min size
|
||||||
if ((connection->main_file_size != -1
|
if (((connection->main_file_size != -1) &&
|
||||||
&& do_ftpsearch == TRUE) && (connection->main_file_size / 1024 >= rt.min_search_size))
|
(do_ftpsearch == TRUE)) && (connection->main_file_size / 1024 >= rt.min_search_size))
|
||||||
{
|
{
|
||||||
status = DL_FTPSEARCHING;
|
status = DL_FTPSEARCHING;
|
||||||
|
|
||||||
@ -377,22 +393,21 @@ DL_Window::handle_info_thread ()
|
|||||||
"http://ftpsearch.elmundo.es:8000/ftpsearch",
|
"http://ftpsearch.elmundo.es:8000/ftpsearch",
|
||||||
LYCOS, rt.ftps_mirror_req_n);
|
LYCOS, rt.ftps_mirror_req_n);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (connection->main_file_size / 1024 >= rt.min_search_size && (do_ftpsearch == TRUE))
|
if ((connection->main_file_size / 1024 >= rt.min_search_size) && (do_ftpsearch == TRUE))
|
||||||
|
{
|
||||||
PrintMessage("File size is less than the minimum, skipping ftpsearch");
|
PrintMessage("File size is less than the minimum, skipping ftpsearch");
|
||||||
|
}
|
||||||
|
|
||||||
do_download();
|
do_download();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ((connection->err == FTPNSFOD) ||
|
||||||
if (connection->err == FTPNSFOD
|
(connection->err == HTTPNSFOD))
|
||||||
|| connection->err == HTTPNSFOD)
|
|
||||||
{
|
{
|
||||||
PrintMessage("The URL %s doesnt exist!\n",
|
PrintMessage("The URL %s doesnt exist!\n",
|
||||||
connection->u.url);
|
connection->u.url);
|
||||||
@ -408,7 +423,6 @@ DL_Window::handle_info_thread ()
|
|||||||
got_info = FALSE;
|
got_info = FALSE;
|
||||||
status = DL_FATALERR;
|
status = DL_FATALERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,8 +431,8 @@ DL_Window::handle_info_thread ()
|
|||||||
void
|
void
|
||||||
DL_Window::handle_ftpsearch()
|
DL_Window::handle_ftpsearch()
|
||||||
{
|
{
|
||||||
|
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
|
|
||||||
err = ftpsearch_win->callback();
|
err = ftpsearch_win->callback();
|
||||||
if (err == MASSPINGDONE)
|
if (err == MASSPINGDONE)
|
||||||
{
|
{
|
||||||
@ -455,10 +469,10 @@ DL_Window::handle_ftpsearch ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::handle_download_thread()
|
DL_Window::handle_download_thread()
|
||||||
{
|
{
|
||||||
|
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
struct timeval cur_time;
|
struct timeval cur_time;
|
||||||
struct timeval diff_time;
|
struct timeval diff_time;
|
||||||
@ -470,10 +484,9 @@ DL_Window::handle_download_thread ()
|
|||||||
|
|
||||||
proz_timeval_subtract(&diff_time, &cur_time, &update_time);
|
proz_timeval_subtract(&diff_time, &cur_time, &update_time);
|
||||||
|
|
||||||
if ((((diff_time.tv_sec * 1000) + (diff_time.tv_usec / 1000)) > 200)
|
if ((((diff_time.tv_sec * 1000) + (diff_time.tv_usec / 1000)) > 200) ||
|
||||||
|| err == DLDONE)
|
(err == DLDONE))
|
||||||
{
|
{
|
||||||
|
|
||||||
print_status(download, rt.quiet_mode);
|
print_status(download, rt.quiet_mode);
|
||||||
|
|
||||||
if (download->main_file_size != -1)
|
if (download->main_file_size != -1)
|
||||||
@ -507,7 +520,6 @@ DL_Window::handle_download_thread ()
|
|||||||
|
|
||||||
if (err == DLLOCALFATAL)
|
if (err == DLLOCALFATAL)
|
||||||
{
|
{
|
||||||
|
|
||||||
PrintMessage("One connection of the download %s encountered a unrecoverable local error, usually lack of free space, or a write to bad medium, or a problem with permissions,so please fix this and retry\n",
|
PrintMessage("One connection of the download %s encountered a unrecoverable local error, usually lack of free space, or a write to bad medium, or a problem with permissions,so please fix this and retry\n",
|
||||||
connection->u.url);
|
connection->u.url);
|
||||||
got_dl = FALSE;
|
got_dl = FALSE;
|
||||||
@ -517,21 +529,18 @@ DL_Window::handle_download_thread ()
|
|||||||
|
|
||||||
if (err == DLREMOTEFATAL)
|
if (err == DLREMOTEFATAL)
|
||||||
{
|
{
|
||||||
|
|
||||||
PrintMessage(_
|
PrintMessage(_
|
||||||
("A connection(s) of the download %s encountered a unrecoverable remote error, usually the file not being present in the remote server, therefore the download had to be aborted!\n"),
|
("A connection(s) of the download %s encountered a unrecoverable remote error, usually the file not being present in the remote server, therefore the download had to be aborted!\n"),
|
||||||
connection->u.url);
|
connection->u.url);
|
||||||
got_dl = FALSE;
|
got_dl = FALSE;
|
||||||
status = DL_FATALERR;
|
status = DL_FATALERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::handle_joining_thread()
|
DL_Window::handle_joining_thread()
|
||||||
{
|
{
|
||||||
|
|
||||||
boolean bDone = false;
|
boolean bDone = false;
|
||||||
|
|
||||||
uerr_t building_status = proz_download_get_join_status(download);
|
uerr_t building_status = proz_download_get_join_status(download);
|
||||||
@ -543,12 +552,10 @@ DL_Window::handle_joining_thread ()
|
|||||||
proz_download_wait_till_end_joining_thread(download);
|
proz_download_wait_till_end_joining_thread(download);
|
||||||
joining_thread_running = FALSE;
|
joining_thread_running = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (building_status == JOINDONE)
|
if (building_status == JOINDONE)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (joining_thread_running == TRUE)
|
if (joining_thread_running == TRUE)
|
||||||
{
|
{
|
||||||
proz_download_wait_till_end_joining_thread(download);
|
proz_download_wait_till_end_joining_thread(download);
|
||||||
@ -573,26 +580,24 @@ DL_Window::handle_joining_thread ()
|
|||||||
void
|
void
|
||||||
DL_Window::handle_dl_fatal_error()
|
DL_Window::handle_dl_fatal_error()
|
||||||
{
|
{
|
||||||
|
|
||||||
status = DL_FATALERR;
|
status = DL_FATALERR;
|
||||||
cleanup(FALSE);
|
cleanup(FALSE);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DL_Window::print_status(download_t *download, int quiet_mode)
|
DL_Window::print_status(download_t *download, int quiet_mode)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (rt.display_mode == DISP_CURSES)
|
if (rt.display_mode == DISP_CURSES)
|
||||||
|
{
|
||||||
DisplayCursesInfo(download);
|
DisplayCursesInfo(download);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (quiet_mode == FALSE)
|
if (quiet_mode == FALSE)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < download->num_connections; i++)
|
for (int i = 0; i < download->num_connections; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"%2.2d %-30.30s %15.15s %10zd\n",
|
"%2.2d %-30.30s %15.15s %10zd\n",
|
||||||
i + 1, download->pconnections[i]->u.host,
|
i + 1, download->pconnections[i]->u.host,
|
||||||
@ -619,17 +624,25 @@ DL_Window::print_status (download_t * download, int quiet_mode)
|
|||||||
proz_download_get_est_time_left(download)) != -1)
|
proz_download_get_est_time_left(download)) != -1)
|
||||||
{
|
{
|
||||||
if (secs_left < 60)
|
if (secs_left < 60)
|
||||||
|
{
|
||||||
snprintf(timeLeft, sizeof(timeLeft), "00:%.2d", secs_left);
|
snprintf(timeLeft, sizeof(timeLeft), "00:%.2d", secs_left);
|
||||||
|
}
|
||||||
else if (secs_left < 3600)
|
else if (secs_left < 3600)
|
||||||
|
{
|
||||||
snprintf(timeLeft, sizeof(timeLeft), "00:%.2d:%.2d",
|
snprintf(timeLeft, sizeof(timeLeft), "00:%.2d:%.2d",
|
||||||
secs_left / 60, secs_left % 60);
|
secs_left / 60, secs_left % 60);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
snprintf(timeLeft, sizeof(timeLeft), "%.2d:%.2d:00",
|
snprintf(timeLeft, sizeof(timeLeft), "%.2d:%.2d:00",
|
||||||
secs_left / 3600,
|
secs_left / 3600,
|
||||||
(secs_left % 3600) / 60);
|
(secs_left % 3600) / 60);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
sprintf(timeLeft, "??:??:??");
|
sprintf(timeLeft, "??:??:??");
|
||||||
|
}
|
||||||
|
|
||||||
off_t totalDownloaded = 0;
|
off_t totalDownloaded = 0;
|
||||||
off_t totalFile = 0;
|
off_t totalFile = 0;
|
||||||
@ -650,6 +663,7 @@ DL_Window::print_status (download_t * download, int quiet_mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DL_Window::askUserResume(connection_t *connection, boolean resumeSupported)
|
int DL_Window::askUserResume(connection_t *connection, boolean resumeSupported)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -657,9 +671,12 @@ int DL_Window::askUserResume(connection_t *connection, boolean resumeSupported)
|
|||||||
const char msg2[] = "Previous download of %s exists, would you like to (A)bort it or (O)verwrite it?";
|
const char msg2[] = "Previous download of %s exists, would you like to (A)bort it or (O)verwrite it?";
|
||||||
|
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
if (rt.display_mode == DISP_CURSES)
|
if (rt.display_mode == DISP_CURSES)
|
||||||
|
{
|
||||||
ret = curses_query_user_input((resumeSupported == TRUE) ? msg : msg2, connection->u.file);
|
ret = curses_query_user_input((resumeSupported == TRUE) ? msg : msg2, connection->u.file);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
@ -672,23 +689,28 @@ int DL_Window::askUserResume(connection_t *connection, boolean resumeSupported)
|
|||||||
{
|
{
|
||||||
case 'O':
|
case 'O':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'A':
|
case 'A':
|
||||||
if (resumeSupported == TRUE)
|
if (resumeSupported == TRUE)
|
||||||
|
{
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
if (resumeSupported == FALSE)
|
if (resumeSupported == FALSE)
|
||||||
|
{
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (ret == 0);
|
} while (ret == 0);
|
||||||
|
|
||||||
return ret;
|
return(ret);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -698,9 +720,12 @@ int DL_Window::askUserOverwrite(connection_t *connectionb)
|
|||||||
const char msg[] = "File %s already exists, would you like to (A)bort it or (O)verwrite it?";
|
const char msg[] = "File %s already exists, would you like to (A)bort it or (O)verwrite it?";
|
||||||
|
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
if (rt.display_mode == DISP_CURSES)
|
if (rt.display_mode == DISP_CURSES)
|
||||||
|
{
|
||||||
ret = curses_query_user_input(msg, connection->u.file);
|
ret = curses_query_user_input(msg, connection->u.file);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
@ -713,14 +738,15 @@ int DL_Window::askUserOverwrite(connection_t *connectionb)
|
|||||||
{
|
{
|
||||||
case 'O':
|
case 'O':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'A':
|
case 'A':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (ret == 0);
|
} while (ret == 0);
|
||||||
|
|
||||||
return ret;
|
return(ret);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ typedef enum {
|
|||||||
} dlg_class;
|
} dlg_class;
|
||||||
|
|
||||||
class DL_Window {
|
class DL_Window {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DL_Window(urlinfo * url_data);
|
DL_Window(urlinfo * url_data);
|
||||||
~DL_Window();
|
~DL_Window();
|
||||||
|
@ -68,7 +68,6 @@ FTPS_Window::fetch_mirror_info (urlinfo * u, off_t file_size,
|
|||||||
uerr_t
|
uerr_t
|
||||||
FTPS_Window::callback()
|
FTPS_Window::callback()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (request_running == TRUE)
|
if (request_running == TRUE)
|
||||||
{
|
{
|
||||||
if (proz_request_info_running(request) == FALSE)
|
if (proz_request_info_running(request) == FALSE)
|
||||||
@ -103,7 +102,6 @@ FTPS_Window::callback ()
|
|||||||
|
|
||||||
if (ping_running == TRUE)
|
if (ping_running == TRUE)
|
||||||
{
|
{
|
||||||
|
|
||||||
print_status(request, rt.quiet_mode);
|
print_status(request, rt.quiet_mode);
|
||||||
|
|
||||||
if (proz_request_mass_ping_running(request) == FALSE)
|
if (proz_request_mass_ping_running(request) == FALSE)
|
||||||
@ -145,7 +143,6 @@ FTPS_Window::cleanup ()
|
|||||||
void
|
void
|
||||||
cb_exit_ftpsearch(void *data)
|
cb_exit_ftpsearch(void *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
FTPS_Window *window = (FTPS_Window *)data;
|
FTPS_Window *window = (FTPS_Window *)data;
|
||||||
|
|
||||||
window->exit_ftpsearch_button_pressed = TRUE;
|
window->exit_ftpsearch_button_pressed = TRUE;
|
||||||
@ -177,17 +174,20 @@ void FTPS_Window::print_status(ftps_request_t *request, int quiet_mode)
|
|||||||
request->mirrors[i].server_name,
|
request->mirrors[i].server_name,
|
||||||
"NOT TESTED");
|
"NOT TESTED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESPONSEOK:
|
case RESPONSEOK:
|
||||||
DisplayInfo(i + 1, 1, "%-30.30s %dms\n",
|
DisplayInfo(i + 1, 1, "%-30.30s %dms\n",
|
||||||
request->mirrors[i].server_name,
|
request->mirrors[i].server_name,
|
||||||
request->mirrors[i].milli_secs);
|
request->mirrors[i].milli_secs);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORESPONSE:
|
case NORESPONSE:
|
||||||
case ERROR:
|
case ERROR:
|
||||||
DisplayInfo(i + 1, 1, "%-30.30s %s\n",
|
DisplayInfo(i + 1, 1, "%-30.30s %s\n",
|
||||||
request->mirrors[i].server_name,
|
request->mirrors[i].server_name,
|
||||||
"NO REPONSE");
|
"NO REPONSE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DisplayInfo(i + 1, 1, "%-30.30s %s\n",
|
DisplayInfo(i + 1, 1, "%-30.30s %s\n",
|
||||||
request->mirrors[i].server_name,
|
request->mirrors[i].server_name,
|
||||||
@ -197,7 +197,5 @@ void FTPS_Window::print_status(ftps_request_t *request, int quiet_mode)
|
|||||||
}
|
}
|
||||||
if (rt.display_mode == DISP_STDOUT)
|
if (rt.display_mode == DISP_STDOUT)
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,6 @@ public:
|
|||||||
boolean exit_ftpsearch_button_pressed;
|
boolean exit_ftpsearch_button_pressed;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<title>Test Page for Apache Installation</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<p>If you can see this, it means that the installation of the <a
|
|
||||||
href="http://www.apache.org/foundation/preFAQ.html">Apache web server</a>
|
|
||||||
software on this system was successful. You may now add content to this
|
|
||||||
directory and replace this page.</p>
|
|
||||||
|
|
||||||
<hr style="width: 100%; height: 3px;" />
|
|
||||||
|
|
||||||
<h2 style="text-align: center">Seeing this instead of the website you expected?</h2>
|
|
||||||
|
|
||||||
<p>This page is here because the site administrator has changed the
|
|
||||||
configuration of this web server. Please <strong>contact the person
|
|
||||||
responsible for maintaining this server with questions.</strong>
|
|
||||||
The Apache Software Foundation, which wrote the web server software
|
|
||||||
this site administrator is using, has nothing to do with
|
|
||||||
maintaining this site and cannot help resolve configuration
|
|
||||||
issues.</p>
|
|
||||||
|
|
||||||
<hr style="width: 100%; height: 3px;" />
|
|
||||||
|
|
||||||
<p>The Apache documentation is available
|
|
||||||
<a href="http://httpd.apache.org/docs-2.0/">online</a> or has been installed
|
|
||||||
<a href="/manual/">locally</a>.</p>
|
|
||||||
|
|
||||||
<p>You are free to use the image below on an Apache-powered web
|
|
||||||
server. Thanks for using Apache!</p>
|
|
||||||
|
|
||||||
<div style="text-align: center"><img src="apache_pb.gif" alt="" /></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -46,9 +46,9 @@ extern struct runtime rt;
|
|||||||
/* Sets the default config */
|
/* Sets the default config */
|
||||||
void set_defaults()
|
void set_defaults()
|
||||||
{
|
{
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Zero the structure which holds the config data
|
* Zero the structure which holds the config data
|
||||||
*/
|
*/
|
||||||
@ -83,7 +83,8 @@ void set_defaults()
|
|||||||
(_("unable to create the directory to store the config info in"));
|
(_("unable to create the directory to store the config info in"));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
perror(_("Error while stating the config info directory"));
|
perror(_("Error while stating the config info directory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +202,6 @@ void set_runtime_values()
|
|||||||
|
|
||||||
void cleanuprt()
|
void cleanuprt()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (rt.config_dir != 0)
|
if (rt.config_dir != 0)
|
||||||
free(rt.config_dir);
|
free(rt.config_dir);
|
||||||
|
|
||||||
@ -222,5 +222,4 @@ void cleanuprt()
|
|||||||
|
|
||||||
if (rt.logfile_dir != 0)
|
if (rt.logfile_dir != 0)
|
||||||
free(rt.logfile_dir);
|
free(rt.logfile_dir);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
* CONREJECTED,
|
* CONREJECTED,
|
||||||
* REMOTEFATAL,
|
* REMOTEFATAL,
|
||||||
* LOCALFATAL
|
* LOCALFATAL
|
||||||
*} dl_status;
|
**} dl_status;
|
||||||
*
|
*
|
||||||
* And here are the texts for the above enums.
|
* And here are the texts for the above enums.
|
||||||
*/
|
*/
|
||||||
@ -120,6 +120,7 @@ void curses_message(char *message)
|
|||||||
short i;
|
short i;
|
||||||
int x, y;
|
int x, y;
|
||||||
attr_t attrs;
|
attr_t attrs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock the mutex
|
* Lock the mutex
|
||||||
*/
|
*/
|
||||||
@ -150,7 +151,6 @@ void curses_message(char *message)
|
|||||||
|
|
||||||
move(y, x);
|
move(y, x);
|
||||||
pthread_mutex_unlock(&curses_msg_mutex);
|
pthread_mutex_unlock(&curses_msg_mutex);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -184,8 +184,7 @@ int curses_query_user_input(const char *args, ...)
|
|||||||
{
|
{
|
||||||
napms(20);
|
napms(20);
|
||||||
ch = getch();
|
ch = getch();
|
||||||
}
|
} while (ch == ERR);
|
||||||
while (ch == ERR);
|
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
noecho();
|
noecho();
|
||||||
@ -220,9 +219,7 @@ void initCurses()
|
|||||||
|
|
||||||
void shutdownCurses()
|
void shutdownCurses()
|
||||||
{
|
{
|
||||||
|
|
||||||
endwin();
|
endwin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -282,6 +279,7 @@ void DisplayCursesInfo(download_t * download )
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int line = 1;
|
int line = 1;
|
||||||
int secs_left;
|
int secs_left;
|
||||||
|
|
||||||
// erase();
|
// erase();
|
||||||
refresh();
|
refresh();
|
||||||
attrset(COLOR_PAIR(HIGHLIGHT_PAIR) | A_BOLD);
|
attrset(COLOR_PAIR(HIGHLIGHT_PAIR) | A_BOLD);
|
||||||
|
23
src/main.cpp
23
src/main.cpp
@ -194,7 +194,6 @@ ms (const char *msg, void *cb_data)
|
|||||||
int
|
int
|
||||||
open_new_dl_win(urlinfo * url_data, boolean ftpsearch)
|
open_new_dl_win(urlinfo * url_data, boolean ftpsearch)
|
||||||
{
|
{
|
||||||
|
|
||||||
dl_win = new DL_Window(url_data);
|
dl_win = new DL_Window(url_data);
|
||||||
|
|
||||||
dl_win->dl_start(rt.num_connections, ftpsearch);
|
dl_win->dl_start(rt.num_connections, ftpsearch);
|
||||||
@ -221,6 +220,7 @@ main (int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
int ret;
|
int ret;
|
||||||
char *opt_file = NULL;
|
char *opt_file = NULL;
|
||||||
|
|
||||||
proz_init(argc, argv); //init libprozilla
|
proz_init(argc, argv); //init libprozilla
|
||||||
set_defaults(); //set some reasonable defaults
|
set_defaults(); //set some reasonable defaults
|
||||||
load_prefs(); //load values from the config file
|
load_prefs(); //load values from the config file
|
||||||
@ -234,18 +234,23 @@ main (int argc, char **argv)
|
|||||||
case 'L':
|
case 'L':
|
||||||
license();
|
license();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
help();
|
help();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'V':
|
case 'V':
|
||||||
version();
|
version();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
rt.resume_mode = RESUME;
|
rt.resume_mode = RESUME;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
rt.force_mode = TRUE;
|
rt.force_mode = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'k':
|
case 'k':
|
||||||
if (setargval(optarg, &rt.num_connections) != 1)
|
if (setargval(optarg, &rt.num_connections) != 1)
|
||||||
{
|
{
|
||||||
@ -263,6 +268,7 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
if (setargval(optarg, &rt.max_attempts) != 1)
|
if (setargval(optarg, &rt.max_attempts) != 1)
|
||||||
{
|
{
|
||||||
@ -273,28 +279,33 @@ main (int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'n':
|
case 'n':
|
||||||
/*
|
/*
|
||||||
* Don't use ~/.netrc"
|
* Don't use ~/.netrc"
|
||||||
*/
|
*/
|
||||||
rt.use_netrc = FALSE;
|
rt.use_netrc = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'O':
|
case 'O':
|
||||||
/*
|
/*
|
||||||
* Output file name
|
* Output file name
|
||||||
*/
|
*/
|
||||||
opt_file = kstrdup(optarg);
|
opt_file = kstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
/*
|
/*
|
||||||
* Save the downloaded file to DIR
|
* Save the downloaded file to DIR
|
||||||
*/
|
*/
|
||||||
rt.output_dir = kstrdup(optarg);
|
rt.output_dir = kstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
help();
|
help();
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '1':
|
case '1':
|
||||||
rt.num_connections = 1;
|
rt.num_connections = 1;
|
||||||
break;
|
break;
|
||||||
@ -314,6 +325,7 @@ main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
rt.ftp_use_pasv = FALSE;
|
rt.ftp_use_pasv = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 130:
|
case 130:
|
||||||
/*
|
/*
|
||||||
* retry-delay option
|
* retry-delay option
|
||||||
@ -327,6 +339,7 @@ main (int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 131:
|
case 131:
|
||||||
/*--timout option */
|
/*--timout option */
|
||||||
if (setargval(optarg, &rt.itimeout) != 1)
|
if (setargval(optarg, &rt.itimeout) != 1)
|
||||||
@ -338,6 +351,7 @@ main (int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 132:
|
case 132:
|
||||||
/* --no-getch option */
|
/* --no-getch option */
|
||||||
rt.dont_prompt = TRUE;
|
rt.dont_prompt = TRUE;
|
||||||
@ -382,6 +396,7 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 137:
|
case 137:
|
||||||
/* --pao option */
|
/* --pao option */
|
||||||
if (setargval(optarg, &rt.max_simul_pings) != 1)
|
if (setargval(optarg, &rt.max_simul_pings) != 1)
|
||||||
@ -419,6 +434,7 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 139:
|
case 139:
|
||||||
/* --max-bps */
|
/* --max-bps */
|
||||||
if (setlongargval(optarg, &rt.max_bps_per_dl) != 1)
|
if (setlongargval(optarg, &rt.max_bps_per_dl) != 1)
|
||||||
@ -430,9 +446,11 @@ main (int argc, char **argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 140:
|
case 140:
|
||||||
rt.display_mode = DISP_STDOUT;
|
rt.display_mode = DISP_STDOUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 141:
|
case 141:
|
||||||
/* --min-size */
|
/* --min-size */
|
||||||
if (setlongargval(optarg, &rt.min_search_size) != 1)
|
if (setlongargval(optarg, &rt.min_search_size) != 1)
|
||||||
@ -541,17 +559,14 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
shutdown();
|
shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown(void)
|
void shutdown(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
cleanuprt();
|
cleanuprt();
|
||||||
|
|
||||||
if (rt.display_mode == DISP_CURSES)
|
if (rt.display_mode == DISP_CURSES)
|
||||||
shutdownCurses();
|
shutdownCurses();
|
||||||
|
|
||||||
proz_shutdown();
|
proz_shutdown();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
23
src/misc.cpp
23
src/misc.cpp
@ -29,7 +29,6 @@ char *kstrdup(const char *s)
|
|||||||
// die("Not enough memory to continue: strdup failed");
|
// die("Not enough memory to continue: strdup failed");
|
||||||
}
|
}
|
||||||
return s1;
|
return s1;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Extracts a numurical argument from a option,
|
/* Extracts a numurical argument from a option,
|
||||||
when it has been specified for example as -l=3 or, -l3
|
when it has been specified for example as -l=3 or, -l3
|
||||||
@ -44,23 +43,24 @@ int setargval(char *optstr, int *num)
|
|||||||
{
|
{
|
||||||
*num = atoi(optstr + 1);
|
*num = atoi(optstr + 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (is_number(optstr) == 1)
|
if (is_number(optstr) == 1)
|
||||||
{
|
{
|
||||||
*num = atoi(optstr);
|
*num = atoi(optstr);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int setlongargval(char *optstr, long *num)
|
int setlongargval(char *optstr, long *num)
|
||||||
@ -71,23 +71,24 @@ int setlongargval(char *optstr, long *num)
|
|||||||
{
|
{
|
||||||
*num = atol(optstr + 1);
|
*num = atol(optstr + 1);
|
||||||
return 1;
|
return 1;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (is_number(optstr) == 1)
|
if (is_number(optstr) == 1)
|
||||||
{
|
{
|
||||||
*num = atol(optstr);
|
*num = atol(optstr);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
} else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void delay_ms(int ms)
|
void delay_ms(int ms)
|
||||||
|
108
src/prefs.cpp
108
src/prefs.cpp
@ -107,11 +107,11 @@ prefopt_t pref_opts[] = {
|
|||||||
|
|
||||||
void set_num_threads(int i, const char *const val, FILE * const fp)
|
void set_num_threads(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.num_connections);
|
fprintf(fp, "%d", rt.num_connections);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.num_connections = atoi(val);
|
rt.num_connections = atoi(val);
|
||||||
if (rt.num_connections <= 0 || rt.num_connections > 30)
|
if (rt.num_connections <= 0 || rt.num_connections > 30)
|
||||||
@ -125,7 +125,8 @@ void set_max_attempts(int i, const char *const val, FILE * const fp)
|
|||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.max_attempts);
|
fprintf(fp, "%d", rt.max_attempts);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.max_attempts = atoi(val);
|
rt.max_attempts = atoi(val);
|
||||||
if (rt.max_attempts < 0)
|
if (rt.max_attempts < 0)
|
||||||
@ -138,7 +139,8 @@ void set_retry_delay(int i, const char *const val, FILE * const fp)
|
|||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.retry_delay);
|
fprintf(fp, "%d", rt.retry_delay);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.retry_delay = atoi(val);
|
rt.retry_delay = atoi(val);
|
||||||
if (rt.retry_delay < 0)
|
if (rt.retry_delay < 0)
|
||||||
@ -152,7 +154,8 @@ void set_conn_timeout(int i, const char *const val, FILE * const fp)
|
|||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", (int)rt.timeout.tv_sec);
|
fprintf(fp, "%d", (int)rt.timeout.tv_sec);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.timeout.tv_sec = atoi(val);
|
rt.timeout.tv_sec = atoi(val);
|
||||||
rt.timeout.tv_usec = 0;
|
rt.timeout.tv_usec = 0;
|
||||||
@ -168,37 +171,36 @@ void set_max_bps_per_dl(int i, const char *const val, FILE * const fp)
|
|||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", (int)rt.max_bps_per_dl);
|
fprintf(fp, "%d", (int)rt.max_bps_per_dl);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.max_bps_per_dl = atoi(val);
|
rt.max_bps_per_dl = atoi(val);
|
||||||
|
|
||||||
if (rt.max_bps_per_dl < 0)
|
if (rt.max_bps_per_dl < 0)
|
||||||
rt.max_bps_per_dl = 0;
|
rt.max_bps_per_dl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_use_pasv(int i, const char *const val, FILE * const fp)
|
void set_use_pasv(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.ftp_use_pasv);
|
fprintf(fp, "%d", rt.ftp_use_pasv);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.ftp_use_pasv = atoi(val);
|
rt.ftp_use_pasv = atoi(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void set_debug_mode(int i, const char *const val, FILE * const fp)
|
void set_debug_mode(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.debug_mode);
|
fprintf(fp, "%d", rt.debug_mode);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.debug_mode = atoi(val);
|
rt.debug_mode = atoi(val);
|
||||||
}
|
}
|
||||||
@ -206,11 +208,11 @@ void set_debug_mode(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_libdebug_mode(int i, const char *const val, FILE * const fp)
|
void set_libdebug_mode(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.libdebug_mode);
|
fprintf(fp, "%d", rt.libdebug_mode);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.libdebug_mode = atoi(val);
|
rt.libdebug_mode = atoi(val);
|
||||||
}
|
}
|
||||||
@ -218,11 +220,11 @@ void set_libdebug_mode(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_http_no_cache(int i, const char *const val, FILE * const fp)
|
void set_http_no_cache(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.http_no_cache);
|
fprintf(fp, "%d", rt.http_no_cache);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.http_no_cache = atoi(val);
|
rt.http_no_cache = atoi(val);
|
||||||
}
|
}
|
||||||
@ -233,18 +235,17 @@ void set_output_dir(int i, const char *const val, FILE * const fp)
|
|||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s", rt.output_dir);
|
fprintf(fp, "%s", rt.output_dir);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
free(rt.output_dir);
|
free(rt.output_dir);
|
||||||
rt.output_dir = strdup(val);
|
rt.output_dir = strdup(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void set_http_proxy(int i, const char *const val, FILE * const fp)
|
void set_http_proxy(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
urlinfo url_data;
|
urlinfo url_data;
|
||||||
|
|
||||||
@ -252,7 +253,8 @@ void set_http_proxy(int i, const char *const val, FILE * const fp)
|
|||||||
{
|
{
|
||||||
fprintf(fp, "%s:%d", rt.http_proxy->proxy_url.host,
|
fprintf(fp, "%s:%d", rt.http_proxy->proxy_url.host,
|
||||||
rt.http_proxy->proxy_url.port);
|
rt.http_proxy->proxy_url.port);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
err = proz_parse_url(val, &url_data, 0);
|
err = proz_parse_url(val, &url_data, 0);
|
||||||
if (err != URLOK)
|
if (err != URLOK)
|
||||||
@ -267,11 +269,11 @@ void set_http_proxy(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_http_proxy_username(int i, const char *const val, FILE * const fp)
|
void set_http_proxy_username(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s", rt.http_proxy->username);
|
fprintf(fp, "%s", rt.http_proxy->username);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
free(rt.http_proxy->username);
|
free(rt.http_proxy->username);
|
||||||
rt.http_proxy->username = strdup(val);
|
rt.http_proxy->username = strdup(val);
|
||||||
@ -282,11 +284,11 @@ void set_http_proxy_username(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_http_proxy_passwd(int i, const char *const val, FILE * const fp)
|
void set_http_proxy_passwd(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s", rt.http_proxy->passwd);
|
fprintf(fp, "%s", rt.http_proxy->passwd);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
free(rt.http_proxy->passwd);
|
free(rt.http_proxy->passwd);
|
||||||
rt.http_proxy->passwd = strdup(val);
|
rt.http_proxy->passwd = strdup(val);
|
||||||
@ -296,11 +298,11 @@ void set_http_proxy_passwd(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_http_proxy_type(int i, const char *const val, FILE * const fp)
|
void set_http_proxy_type(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", (int)rt.http_proxy->type);
|
fprintf(fp, "%d", (int)rt.http_proxy->type);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.http_proxy->type = (proxy_type)atoi(val);
|
rt.http_proxy->type = (proxy_type)atoi(val);
|
||||||
}
|
}
|
||||||
@ -310,11 +312,11 @@ void set_http_proxy_type(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_http_use_proxy(int i, const char *const val, FILE * const fp)
|
void set_http_use_proxy(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.use_http_proxy);
|
fprintf(fp, "%d", rt.use_http_proxy);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.use_http_proxy = atoi(val);
|
rt.use_http_proxy = atoi(val);
|
||||||
}
|
}
|
||||||
@ -325,7 +327,6 @@ void set_http_use_proxy(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_ftp_proxy(int i, const char *const val, FILE * const fp)
|
void set_ftp_proxy(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
uerr_t err;
|
uerr_t err;
|
||||||
urlinfo url_data;
|
urlinfo url_data;
|
||||||
|
|
||||||
@ -333,7 +334,8 @@ void set_ftp_proxy(int i, const char *const val, FILE * const fp)
|
|||||||
{
|
{
|
||||||
fprintf(fp, "%s:%d", rt.ftp_proxy->proxy_url.host,
|
fprintf(fp, "%s:%d", rt.ftp_proxy->proxy_url.host,
|
||||||
rt.ftp_proxy->proxy_url.port);
|
rt.ftp_proxy->proxy_url.port);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
err = proz_parse_url(val, &url_data, 0);
|
err = proz_parse_url(val, &url_data, 0);
|
||||||
if (err != URLOK)
|
if (err != URLOK)
|
||||||
@ -348,11 +350,11 @@ void set_ftp_proxy(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_ftp_proxy_username(int i, const char *const val, FILE * const fp)
|
void set_ftp_proxy_username(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s", rt.ftp_proxy->username);
|
fprintf(fp, "%s", rt.ftp_proxy->username);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
free(rt.ftp_proxy->username);
|
free(rt.ftp_proxy->username);
|
||||||
rt.ftp_proxy->username = strdup(val);
|
rt.ftp_proxy->username = strdup(val);
|
||||||
@ -362,11 +364,11 @@ void set_ftp_proxy_username(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_ftp_proxy_passwd(int i, const char *const val, FILE * const fp)
|
void set_ftp_proxy_passwd(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s", rt.ftp_proxy->passwd);
|
fprintf(fp, "%s", rt.ftp_proxy->passwd);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
free(rt.ftp_proxy->passwd);
|
free(rt.ftp_proxy->passwd);
|
||||||
rt.ftp_proxy->passwd = strdup(val);
|
rt.ftp_proxy->passwd = strdup(val);
|
||||||
@ -375,11 +377,11 @@ void set_ftp_proxy_passwd(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_ftp_proxy_type(int i, const char *const val, FILE * const fp)
|
void set_ftp_proxy_type(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", (int)rt.ftp_proxy->type);
|
fprintf(fp, "%d", (int)rt.ftp_proxy->type);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.ftp_proxy->type = (proxy_type)atoi(val);
|
rt.ftp_proxy->type = (proxy_type)atoi(val);
|
||||||
}
|
}
|
||||||
@ -387,11 +389,11 @@ void set_ftp_proxy_type(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_ftp_use_proxy(int i, const char *const val, FILE * const fp)
|
void set_ftp_use_proxy(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.use_ftp_proxy);
|
fprintf(fp, "%d", rt.use_ftp_proxy);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.use_ftp_proxy = atoi(val);
|
rt.use_ftp_proxy = atoi(val);
|
||||||
}
|
}
|
||||||
@ -400,11 +402,11 @@ void set_ftp_use_proxy(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_mirrors_req(int i, const char *const val, FILE * const fp)
|
void set_mirrors_req(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.ftps_mirror_req_n);
|
fprintf(fp, "%d", rt.ftps_mirror_req_n);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.ftps_mirror_req_n = atoi(val);
|
rt.ftps_mirror_req_n = atoi(val);
|
||||||
if (rt.ftps_mirror_req_n <= 0 || rt.ftps_mirror_req_n > 1000)
|
if (rt.ftps_mirror_req_n <= 0 || rt.ftps_mirror_req_n > 1000)
|
||||||
@ -414,11 +416,11 @@ void set_mirrors_req(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_max_simul_pings(int i, const char *const val, FILE * const fp)
|
void set_max_simul_pings(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.max_simul_pings);
|
fprintf(fp, "%d", rt.max_simul_pings);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.max_simul_pings = atoi(val);
|
rt.max_simul_pings = atoi(val);
|
||||||
if (rt.max_simul_pings <= 0 || rt.max_simul_pings > 30)
|
if (rt.max_simul_pings <= 0 || rt.max_simul_pings > 30)
|
||||||
@ -430,11 +432,11 @@ void set_max_simul_pings(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_max_ping_wait(int i, const char *const val, FILE * const fp)
|
void set_max_ping_wait(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.max_ping_wait);
|
fprintf(fp, "%d", rt.max_ping_wait);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.max_ping_wait = atoi(val);
|
rt.max_ping_wait = atoi(val);
|
||||||
if (rt.max_ping_wait <= 0 || rt.max_ping_wait > 30)
|
if (rt.max_ping_wait <= 0 || rt.max_ping_wait > 30)
|
||||||
@ -445,15 +447,14 @@ void set_max_ping_wait(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_use_ftpsearch(int i, const char *const val, FILE * const fp)
|
void set_use_ftpsearch(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.ftp_search);
|
fprintf(fp, "%d", rt.ftp_search);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.ftp_search = atoi(val);
|
rt.ftp_search = atoi(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_ftpsearch_server_id(int i, const char *const val, FILE * const fp)
|
void set_ftpsearch_server_id(int i, const char *const val, FILE * const fp)
|
||||||
@ -461,24 +462,24 @@ void set_ftpsearch_server_id(int i, const char *const val, FILE * const fp)
|
|||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.ftpsearch_server_id);
|
fprintf(fp, "%d", rt.ftpsearch_server_id);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.ftpsearch_server_id = atoi(val);
|
rt.ftpsearch_server_id = atoi(val);
|
||||||
if (rt.ftpsearch_server_id < 0)
|
if (rt.ftpsearch_server_id < 0)
|
||||||
rt.ftpsearch_server_id = 0;
|
rt.ftpsearch_server_id = 0;
|
||||||
else if (rt.ftpsearch_server_id > 1)
|
else if (rt.ftpsearch_server_id > 1)
|
||||||
rt.ftpsearch_server_id = 1;
|
rt.ftpsearch_server_id = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_display_mode(int i, const char *const val, FILE * const fp)
|
void set_display_mode(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%d", rt.display_mode);
|
fprintf(fp, "%d", rt.display_mode);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.display_mode = atoi(val);
|
rt.display_mode = atoi(val);
|
||||||
}
|
}
|
||||||
@ -486,11 +487,11 @@ void set_display_mode(int i, const char *const val, FILE * const fp)
|
|||||||
|
|
||||||
void set_search_size(int i, const char *const val, FILE * const fp)
|
void set_search_size(int i, const char *const val, FILE * const fp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%ld", rt.min_search_size);
|
fprintf(fp, "%ld", rt.min_search_size);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
rt.min_search_size = atoi(val);
|
rt.min_search_size = atoi(val);
|
||||||
}
|
}
|
||||||
@ -537,7 +538,6 @@ void load_prefs()
|
|||||||
|
|
||||||
if ((fp = fopen(config_fname, "rt")) == NULL)
|
if ((fp = fopen(config_fname, "rt")) == NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (errno == ENOENT) /*Create the file then if it doesnt exist */
|
if (errno == ENOENT) /*Create the file then if it doesnt exist */
|
||||||
{
|
{
|
||||||
save_prefs();
|
save_prefs();
|
||||||
|
Loading…
Reference in New Issue
Block a user