slp, limit_data.chunk_bytes, limit_data.sleep_adjust));
t0 = *dltime;
- usleep ((unsigned long) (1000 * slp));
+ xsleep (slp / 1000);
t1 = wtimer_elapsed (timer);
/* Due to scheduling, we probably slept slightly longer (or
if (file)
*file = local_file ? local_file : NULL;
else
- FREE_MAYBE (local_file);
+ xfree_null (local_file);
url_free (u);
them. If HTML is non-zero, treat the file as HTML, and construct
the URLs accordingly.
- If opt.recursive is set, call recursive_retrieve() for each file. */
+ If opt.recursive is set, call retrieve_tree() for each file. */
+
uerr_t
retrieve_from_file (const char *file, int html, int *count)
{
status = QUOTEXC;
break;
}
- if (opt.recursive && cur_url->url->scheme != SCHEME_FTP)
+ if ((opt.recursive || opt.page_requisites)
+ && cur_url->url->scheme != SCHEME_FTP)
status = retrieve_tree (cur_url->url->url);
else
status = retrieve_url (cur_url->url->url, &filename, &new_file, NULL, &dt);
dt &= ~RETROKF;
}
- FREE_MAYBE (new_file);
- FREE_MAYBE (filename);
+ xfree_null (new_file);
+ xfree_null (filename);
}
/* Free the linked list of URL-s. */
/* If opt.waitretry is specified and this is a retry, wait for
COUNT-1 number of seconds, or for opt.waitretry seconds. */
if (count <= opt.waitretry)
- sleep (count - 1);
+ xsleep (count - 1);
else
- usleep (1000000L * opt.waitretry);
+ xsleep (opt.waitretry);
}
else if (opt.wait)
{
/* If random-wait is not specified, or if we are sleeping
between retries of the same download, sleep the fixed
interval. */
- usleep (1000000L * opt.wait);
+ xsleep (opt.wait);
else
{
/* Sleep a random amount of time averaging in opt.wait
double waitsecs = 2 * opt.wait * random_float ();
DEBUGP (("sleep_between_retrievals: avg=%f,sleep=%f\n",
opt.wait, waitsecs));
- usleep (1000000L * waitsecs);
+ xsleep (waitsecs);
}
}
}
struct urlpos *next = l->next;
if (l->url)
url_free (l->url);
- FREE_MAYBE (l->local_name);
+ xfree_null (l->local_name);
xfree (l);
l = next;
}