share code between libfetch and libcurl

no actual code changes here. change preprocessor logic to include
get_tempfile, get_destfile, signal handler enum, and the interrupt
handler logic when either HAVE_LIBCURL or HAVE_LIBFETCH are defined.

Signed-off-by: Dave Reisner <d@falconindy.com>
This commit is contained in:
Dave Reisner 2011-01-14 12:17:39 -05:00
parent 159e1b06a5
commit a5b6a75787
1 changed files with 12 additions and 10 deletions

View File

@ -59,7 +59,7 @@ static char *get_filename(const char *url) {
return(filename);
}
#ifdef HAVE_LIBFETCH
#if defined(HAVE_LIBFETCH) || defined(HAVE_LIBCURL)
static char *get_destfile(const char *path, const char *filename) {
char *destfile;
/* len = localpath len + filename len + null */
@ -80,6 +80,17 @@ static char *get_tempfile(const char *path, const char *filename) {
return(tempfile);
}
#define check_stop() if(dload_interrupted) { ret = -1; goto cleanup; }
enum sighandlers { OLD = 0, NEW = 1 };
int dload_interrupted;
static void inthandler(int signum)
{
dload_interrupted = 1;
}
#endif
#ifdef HAVE_LIBFETCH
static const char *fetch_gethost(struct url *fileurl)
{
const char *host = _("disk");
@ -89,15 +100,6 @@ static const char *fetch_gethost(struct url *fileurl)
return(host);
}
int dload_interrupted;
static void inthandler(int signum)
{
dload_interrupted = 1;
}
#define check_stop() if(dload_interrupted) { ret = -1; goto cleanup; }
enum sighandlers { OLD = 0, NEW = 1 };
static int fetch_download_internal(const char *url, const char *localpath,
int force) {
FILE *localf = NULL;