bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Wget only runs once - need a bit of advice.


From: Ángel González
Subject: Re: [Bug-wget] Wget only runs once - need a bit of advice.
Date: Mon, 16 Jul 2012 22:02:28 +0200
User-agent: Thunderbird

On 16/07/12 15:42, Colin Bell wrote:
> Hi all
>
> I have a modified version of wget 1.13.4 which allows it to run as a
> library. Code can be found here http://pastie.org/pastes/4266045/text
>
> It works well except for the fact that it will only run once. If I execute
> the wget method again it stops because it fails to pass a buffer check (see
> code below). Can anyone give me some ideas on what I'm missing here?
>
> Thanks everyone, very much appreciated.
Well, the reason is simple. no_prefix is writing the passed parameter into a
static buffer, which is never reset. So you can't infinitelly call it
and have it
continue running.
Given that no_prefix is only called by init_switches(), you don't really
need
to call it again. It can be done once.

I'd place at the top of wget (char* param) a static bool initialised,
and replace

defaults() and init_switches() in that function with:
if (!initialised) {
  defaults();
  init_switches();
  initialised = true;
 }


Good luck




reply via email to

[Prev in Thread] Current Thread [Next in Thread]