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
|
2004-02-13 19:09:12 +03:00
|
|
|
* Copyright 2004 James Bursa <bursa@users.sourceforge.net>
|
2003-06-30 16:44:03 +04:00
|
|
|
*/
|
|
|
|
|
2004-03-27 03:54:03 +03:00
|
|
|
#include <assert.h>
|
2003-08-29 16:57:14 +04:00
|
|
|
#include <stdbool.h>
|
2003-06-21 17:18:00 +04:00
|
|
|
#include <string.h>
|
2004-01-05 05:10:59 +03:00
|
|
|
#include "netsurf/utils/config.h"
|
2003-06-21 17:18:00 +04:00
|
|
|
#include "netsurf/content/fetch.h"
|
|
|
|
#include "netsurf/content/cache.h"
|
|
|
|
#include "netsurf/content/content.h"
|
|
|
|
#include "netsurf/content/fetchcache.h"
|
2004-02-13 19:09:12 +03:00
|
|
|
#include "netsurf/desktop/options.h"
|
2003-06-21 17:18:00 +04:00
|
|
|
#include "netsurf/utils/log.h"
|
2004-03-27 03:54:03 +03:00
|
|
|
#include "netsurf/utils/messages.h"
|
|
|
|
#include "netsurf/utils/url.h"
|
2003-11-08 02:52:08 +03:00
|
|
|
#include "netsurf/utils/utils.h"
|
2003-06-21 17:18:00 +04:00
|
|
|
|
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();
|
2003-12-27 23:15:23 +03:00
|
|
|
fetchcache_init();
|
2004-03-27 03:54:03 +03:00
|
|
|
url_init();
|
2004-03-27 21:47:21 +03:00
|
|
|
save_complete_init();
|
2004-02-13 19:09:12 +03:00
|
|
|
options_read("options");
|
2004-03-27 03:54:03 +03:00
|
|
|
messages_load("messages");
|
2003-06-21 17:18:00 +04:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
puts("=== URL:");
|
2003-10-09 00:50:18 +04:00
|
|
|
if (!fgets(url, 1000, stdin))
|
2004-01-02 15:02:01 +03:00
|
|
|
break;
|
2003-10-09 00:50:18 +04:00
|
|
|
url[strlen(url) - 1] = 0;
|
|
|
|
destroyed = 0;
|
2004-02-13 19:09:12 +03:00
|
|
|
c = fetchcache(url, 0, callback, 0, 0, 1000, 1000, false
|
2004-01-20 22:08:34 +03:00
|
|
|
#ifdef WITH_POST
|
|
|
|
, 0, 0
|
|
|
|
#endif
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_COOKIES
|
|
|
|
, true
|
|
|
|
#endif
|
|
|
|
);
|
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();
|
2004-03-27 03:54:03 +03:00
|
|
|
if (!destroyed) {
|
2004-06-03 01:01:52 +04:00
|
|
|
/*while (1)
|
|
|
|
schedule_run();*/
|
2004-03-27 03:54:03 +03:00
|
|
|
/* content_reformat(c, 1, 1000); */
|
2004-04-25 03:42:32 +04:00
|
|
|
/* save_complete(c, "save_complete");*/
|
2004-05-13 18:41:50 +04:00
|
|
|
if (c->type == CONTENT_HTML)
|
|
|
|
box_dump(c->data.html.layout, 0);
|
|
|
|
else if (c->type == CONTENT_CSS)
|
|
|
|
css_dump_stylesheet(c->data.css.css);
|
2004-06-03 01:01:52 +04:00
|
|
|
else if (c->type == CONTENT_GIF)
|
|
|
|
gif_decode_frame(c->data.gif.gif, 0);
|
2003-08-25 20:17:11 +04:00
|
|
|
content_remove_user(c, callback, 0, 0);
|
2004-05-13 18:41:50 +04:00
|
|
|
c = 0;
|
2004-03-27 03:54:03 +03:00
|
|
|
}
|
2003-06-21 17:18:00 +04:00
|
|
|
}
|
|
|
|
|
2004-05-13 18:41:50 +04:00
|
|
|
/* options_write("options"); */
|
2003-06-21 17:18:00 +04:00
|
|
|
cache_quit();
|
|
|
|
fetch_quit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_multitask(void)
|
|
|
|
{
|
2004-03-27 03:54:03 +03:00
|
|
|
/* putchar('-'); */
|
2003-06-21 17:18:00 +04:00
|
|
|
}
|
|
|
|
|
2004-01-02 15:02:01 +03:00
|
|
|
#ifndef riscos
|
2003-06-21 17:18:00 +04:00
|
|
|
int stricmp(char *s0, char *s1)
|
|
|
|
{
|
|
|
|
return strcasecmp(s0, s1);
|
|
|
|
}
|
2004-01-02 15:02:01 +03:00
|
|
|
#endif
|
2003-06-21 17:18:00 +04:00
|
|
|
|
|
|
|
void gui_remove_gadget(void *p)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PLUGIN
|
2003-06-21 17:18:00 +04:00
|
|
|
void plugin_decode(void *a, void *b, void *c, void *d)
|
|
|
|
{
|
|
|
|
}
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2003-06-21 17:18:00 +04:00
|
|
|
|
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,
|
2004-02-25 18:12:58 +03:00
|
|
|
long x0, long y0, long x1, long y1,
|
|
|
|
float scale)
|
2003-07-15 22:11:25 +04:00
|
|
|
{
|
|
|
|
}
|
2003-11-08 02:52:08 +03:00
|
|
|
|
2003-11-15 03:15:40 +03:00
|
|
|
void html_add_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void html_reshape_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void html_remove_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PLUGIN
|
2004-01-02 15:02:01 +03:00
|
|
|
bool plugin_handleable(const char *mime_type)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-01-02 15:02:01 +03:00
|
|
|
|
2004-01-05 05:10:59 +03:00
|
|
|
#ifdef WITH_PLUGIN
|
2004-01-02 15:02:01 +03:00
|
|
|
void plugin_msg_parse(wimp_message *message, int ack) {}
|
2004-05-13 18:41:50 +04:00
|
|
|
void plugin_create(struct content *c, const char *params[]) {}
|
2004-01-02 15:02:01 +03:00
|
|
|
void plugin_process_data(struct content *c, char *data, unsigned long size) {}
|
2004-05-21 00:10:42 +04:00
|
|
|
int plugin_convert(struct content *c, unsigned int width, unsigned int height) {return 0;}
|
2004-01-02 15:02:01 +03:00
|
|
|
void plugin_revive(struct content *c, unsigned int width, unsigned int height) {}
|
|
|
|
void plugin_reformat(struct content *c, unsigned int width, unsigned int height) {}
|
|
|
|
void plugin_destroy(struct content *c) {}
|
|
|
|
void plugin_redraw(struct content *c, long x, long y,
|
|
|
|
unsigned long width, unsigned long height,
|
2004-06-03 01:01:52 +04:00
|
|
|
long clip_x0, long clip_y0, long clip_x1, long clip_y1,
|
|
|
|
float scale) {}
|
2004-01-02 15:02:01 +03:00
|
|
|
void plugin_add_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state) {}
|
|
|
|
void plugin_remove_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state) {}
|
|
|
|
void plugin_reshape_instance(struct content *c, struct browser_window *bw,
|
|
|
|
struct content *page, struct box *box,
|
|
|
|
struct object_params *params, void **state) {}
|
2004-01-05 05:10:59 +03:00
|
|
|
#endif
|
2004-01-02 15:02:01 +03:00
|
|
|
|
2004-06-03 01:01:52 +04:00
|
|
|
#ifdef riscos
|
2004-01-02 15:02:01 +03:00
|
|
|
char *NETSURF_DIR = "<NetSurf$Dir>";
|
|
|
|
#endif
|
|
|
|
|
2004-03-27 03:54:03 +03:00
|
|
|
int colourtrans_return_colour_number_for_mode(int colour, int mode,
|
|
|
|
int *dest_palette)
|
|
|
|
{
|
|
|
|
assert(!dest_palette);
|
|
|
|
return colour;
|
|
|
|
}
|
|
|
|
|
|
|
|
int *xjpeginfo_dimensions(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void xcolourtrans_generate_table_for_sprite(void)
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
os_error *xosspriteop_put_sprite_scaled (osspriteop_flags flags,
|
|
|
|
osspriteop_area const *area,
|
|
|
|
osspriteop_id id,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
osspriteop_action action,
|
|
|
|
os_factors const *factors,
|
|
|
|
osspriteop_trans_tab const *trans_tab)
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
os_error *xos_byte(byte op, int r1, int r2, int *r1_out, int *r2_out)
|
|
|
|
{
|
|
|
|
assert(op == 0x87);
|
|
|
|
*r2_out = 28;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void xjpeg_plot_scaled(void)
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _swix(void)
|
|
|
|
{
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
|
2004-04-14 16:54:20 +04:00
|
|
|
#ifndef riscos
|
2004-03-27 03:54:03 +03:00
|
|
|
bool option_filter_sprites = false;
|
|
|
|
bool option_dither_sprites = false;
|
2004-06-03 01:01:52 +04:00
|
|
|
int option_minimum_gif_delay = 10;
|
2004-04-14 16:54:20 +04:00
|
|
|
#endif
|
2004-03-27 03:54:03 +03:00
|
|
|
|
|
|
|
void die(const char *error)
|
|
|
|
{
|
|
|
|
printf("die: %s\n", error);
|
|
|
|
exit(1);
|
|
|
|
}
|
2004-03-27 21:47:21 +03:00
|
|
|
|
2004-04-14 16:54:20 +04:00
|
|
|
#ifndef riscos
|
2004-03-27 21:47:21 +03:00
|
|
|
int ro_content_filetype(int x)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern os_error *xosfile_save_stamped (char const *file_name,
|
|
|
|
bits file_type,
|
|
|
|
byte const *data,
|
|
|
|
byte const *end)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern os_error *xosfile_set_type (char const *file_name,
|
|
|
|
bits file_type)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-03 01:01:52 +04:00
|
|
|
extern os_t os_read_monotonic_time(void)
|
2004-03-27 21:47:21 +03:00
|
|
|
{
|
2004-06-03 01:01:52 +04:00
|
|
|
return clock() / 10000;
|
2004-04-25 03:42:32 +04:00
|
|
|
}
|
2004-06-03 01:01:52 +04:00
|
|
|
#endif
|
2004-04-25 03:42:32 +04:00
|
|
|
|
2004-06-03 01:01:52 +04:00
|
|
|
void warn_user(const char *warn)
|
2004-04-25 03:42:32 +04:00
|
|
|
{
|
2004-06-03 01:01:52 +04:00
|
|
|
printf("WARNING: %s\n", warn);
|
2004-04-25 03:42:32 +04:00
|
|
|
}
|
2004-05-13 18:41:50 +04:00
|
|
|
|
|
|
|
void *ro_gui_current_redraw_gui = 0;
|