Make metalink check in configure.ac automatic.

This commit is contained in:
Ilim Ugur 2012-07-24 00:47:52 +03:00
parent 26ca40970a
commit 6f102902ad
3 changed files with 28 additions and 29 deletions

View File

@ -95,7 +95,7 @@ test x"${ENABLE_THREADS}" = xyes && AC_DEFINE([ENABLE_THREADS], 1,
AC_ARG_ENABLE(metalink,
[ --disable-metalink disable support for metalink file format],
ENABLE_METALINK=$enableval, ENABLE_METALINK=no)
ENABLE_METALINK=$enableval, ENABLE_METALINK=auto)
test x"${ENABLE_METALINK}" = xyes && AC_DEFINE([ENABLE_METALINK], 1,
[Define if you want the metalink file format support compiled in.])
@ -350,17 +350,28 @@ else
fi
fi
AS_IF([test x"$ENABLE_METALINK" == xyes],[
AS_IF([test x"$ENABLE_METALINK" != xno],[
dnl If metalink support is requested
PKG_CHECK_MODULES(LIBMETALINK, libmetalink, [
dnl If metalink module is found
AC_MSG_NOTICE([compiling in support for metalink])
LIBS="$LIBMETALINK_LIBS $LIBS"
CFLAGS="$LIBMETALINK_CFLAGS $CFLAGS"
metalink=yes
AC_CHECK_LIB(metalink, metalink_parse_file, [
metalink=yes
AC_MSG_NOTICE([compiling in support for metalink])
], [
if test x"$ENABLE_METALINK" == xyes
then
AC_MSG_ERROR([Could not find the metalink_parse_file function in libmetalink.])
fi
])
], [
dnl If metalink module is not found
AC_MSG_ERROR([libmetalink not found])
if test x"$ENABLE_METALINK" == xyes
then
AC_MSG_ERROR([libmetalink not found])
fi
])
],[
dnl If metalink support is not requested

View File

@ -1,18 +0,0 @@
# GNU Wget
# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
include gnulib.mk

View File

@ -66,6 +66,8 @@ static pthread_mutex_t pconn_mutex = PTHREAD_MUTEX_INITIALIZER;
#define PCONN_UNLOCK() pthread_mutex_unlock (&pconn_mutex)
#define TEMP_PREFIX "temp_"
/* Total size of downloaded files. Used to enforce quota. */
SUM_SIZE_INT total_downloaded_bytes;
@ -1039,8 +1041,12 @@ retrieve_from_file (const char *file, bool html, int *count)
{
memset(thread_ctx, '\0', N_THREADS * (sizeof *thread_ctx));
for(k = 0; k < N_THREADS; ++k)
thread_ctx[k].file = malloc(7 + (N_THREADS/10 + 1) +
strlen(file->name));
thread_ctx[k].file = malloc( strlen(TEMP_PREFIX)
+ strlen(file->name)
+ (sizeof ".")-1
+ (N_THREADS/10 + 1) /* simpler than log10,
and close enough */
+ sizeof "" );
chunk_size = (file->size) / N_THREADS;
for(k = 0; k < N_THREADS; ++k)
@ -1101,7 +1107,7 @@ attemptfail: resource = file->resources[j];
if (!opt.base_href)
opt.base_href = xstrdup (url);
sprintf(thread_ctx[index].file, "temp_%s.%d",
sprintf(thread_ctx[index].file, TEMP_PREFIX "%s.%d",
file->name, r);
/* Update this when configuring fallbacking code
@ -1111,7 +1117,7 @@ attemptfail: resource = file->resources[j];
{
command = malloc(15 + (N_THREADS)*(strlen(file->name) +
(N_THREADS/10 + 1) + 2) + strlen(file->name));
sprintf(command, "rm -f temp_%s.*", file->name);
sprintf(command, "rm -f " TEMP_PREFIX "%s.*", file->name);
system(command);
free(command);
}
@ -1228,11 +1234,11 @@ segmentfail: while(free_threads < N_THREADS)
break;
}
}
sem_destroy(&retr_sem);
for(k = 0; k < N_THREADS; ++k)
free(thread_ctx[k].file);
sem_destroy(&retr_sem);
command = malloc(15 + (N_THREADS) * (strlen(file->name) +
(N_THREADS/10 + 1) + 2) + strlen(file->name));
if (status != RETROK)