2003-06-30 16:44:03 +04:00
|
|
|
/*
|
|
|
|
* This file is part of NetSurf, http://netsurf.sourceforge.net/
|
|
|
|
* Licensed under the GNU General Public License,
|
|
|
|
* http://www.opensource.org/licenses/gpl-license
|
|
|
|
* Copyright 2003 James Bursa <bursa@users.sourceforge.net>
|
|
|
|
*/
|
|
|
|
|
2003-08-29 16:57:14 +04:00
|
|
|
#include <stdbool.h>
|
2003-06-21 17:18:00 +04:00
|
|
|
#include <string.h>
|
|
|
|
#include "netsurf/content/fetch.h"
|
|
|
|
#include "netsurf/content/cache.h"
|
|
|
|
#include "netsurf/content/content.h"
|
|
|
|
#include "netsurf/content/fetchcache.h"
|
|
|
|
#include "netsurf/utils/log.h"
|
|
|
|
|
2003-08-25 20:17:11 +04:00
|
|
|
int done, destroyed;
|
2003-06-21 17:18:00 +04:00
|
|
|
|
|
|
|
void callback(content_msg msg, struct content *c, void *p1,
|
|
|
|
void *p2, const char *error)
|
|
|
|
{
|
|
|
|
LOG(("content %s, message %i", c->url, msg));
|
2003-08-25 20:17:11 +04:00
|
|
|
if (msg == CONTENT_MSG_DONE)
|
2003-06-21 17:18:00 +04:00
|
|
|
done = 1;
|
2003-08-25 20:17:11 +04:00
|
|
|
else if (msg == CONTENT_MSG_ERROR)
|
|
|
|
done = destroyed = 1;
|
2003-06-21 17:18:00 +04:00
|
|
|
else if (msg == CONTENT_MSG_STATUS)
|
2003-06-26 15:41:26 +04:00
|
|
|
printf("=== STATUS: %s\n", c->status_message);
|
|
|
|
else if (msg == CONTENT_MSG_REDIRECT) {
|
|
|
|
printf("=== REDIRECT to '%s'\n", error);
|
2003-08-25 20:17:11 +04:00
|
|
|
done = destroyed = 1;
|
2003-06-26 15:41:26 +04:00
|
|
|
}
|
2003-06-21 17:18:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char url[1000];
|
|
|
|
struct content *c;
|
|
|
|
|
|
|
|
fetch_init();
|
|
|
|
cache_init();
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
puts("=== URL:");
|
2003-10-09 00:50:18 +04:00
|
|
|
if (!fgets(url, 1000, stdin))
|
|
|
|
return 0;
|
|
|
|
url[strlen(url) - 1] = 0;
|
|
|
|
destroyed = 0;
|
2003-10-25 18:13:49 +04:00
|
|
|
c = fetchcache(url, 0, callback, 0, 0, 100, 1000, false, 0, 0);
|
2003-07-16 21:38:46 +04:00
|
|
|
if (c) {
|
|
|
|
done = c->status == CONTENT_STATUS_DONE;
|
|
|
|
while (!done)
|
|
|
|
fetch_poll();
|
|
|
|
puts("=== SUCCESS, dumping cache");
|
|
|
|
} else {
|
2003-10-09 00:50:18 +04:00
|
|
|
destroyed = 1;
|
2003-07-16 21:38:46 +04:00
|
|
|
puts("=== FAILURE, dumping cache");
|
|
|
|
}
|
2003-06-21 17:18:00 +04:00
|
|
|
cache_dump();
|
2003-08-25 20:17:11 +04:00
|
|
|
if (!destroyed)
|
|
|
|
content_remove_user(c, callback, 0, 0);
|
2003-06-21 17:18:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cache_quit();
|
|
|
|
fetch_quit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_multitask(void)
|
|
|
|
{
|
|
|
|
LOG(("-"));
|
|
|
|
}
|
|
|
|
|
|
|
|
int stricmp(char *s0, char *s1)
|
|
|
|
{
|
|
|
|
return strcasecmp(s0, s1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_remove_gadget(void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_decode(void *a, void *b, void *c, void *d)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-15 22:11:25 +04:00
|
|
|
void html_redraw(struct content *c, long x, long y,
|
2003-09-10 21:10:25 +04:00
|
|
|
unsigned long width, unsigned long height,
|
|
|
|
long x0, long y0, long x1, long y1)
|
2003-07-15 22:11:25 +04:00
|
|
|
{
|
|
|
|
}
|