summaryrefslogtreecommitdiff
path: root/debug/netsurfd.c
blob: 42e09dd1d277d1103bb517c3f8a891da9b83d243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/*
 * 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 2004 James Bursa <bursa@users.sourceforge.net>
 */

#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include "netsurf/utils/config.h"
#include "netsurf/content/fetch.h"
#include "netsurf/content/cache.h"
#include "netsurf/content/content.h"
#include "netsurf/content/fetchcache.h"
#include "netsurf/desktop/options.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/messages.h"
#include "netsurf/utils/url.h"
#include "netsurf/utils/utils.h"

int done, destroyed;

void callback(content_msg msg, struct content *c, void *p1,
		void *p2, const char *error)
{
	LOG(("content %s, message %i", c->url, msg));
	if (msg == CONTENT_MSG_DONE)
		done = 1;
	else if (msg == CONTENT_MSG_ERROR)
		done = destroyed = 1;
	else if (msg == CONTENT_MSG_STATUS)
		printf("=== STATUS: %s\n", c->status_message);
	else if (msg == CONTENT_MSG_REDIRECT) {
		printf("=== REDIRECT to '%s'\n", error);
		done = destroyed = 1;
	}
}

int main(int argc, char *argv[])
{
	char url[1000];
	struct content *c;

	fetch_init();
	cache_init();
	fetchcache_init();
	url_init();
	save_complete_init();
	options_read("options");
	messages_load("messages");

	while (1) {
		puts("=== URL:");
		if (!fgets(url, 1000, stdin))
			break;
		url[strlen(url) - 1] = 0;
		destroyed = 0;
		c = fetchcache(url, 0, callback, 0, 0, 1000, 1000, false
#ifdef WITH_POST
		, 0, 0
#endif
#ifdef WITH_COOKIES
		, true
#endif
		);
		if (c) {
			done = c->status == CONTENT_STATUS_DONE;
			while (!done)
				fetch_poll();
			puts("=== SUCCESS, dumping cache");
		} else {
			destroyed = 1;
			puts("=== FAILURE, dumping cache");
		}
		cache_dump();
		if (!destroyed) {
/* 			content_reformat(c, 1, 1000); */
			save_complete(c, "save_complete");
			content_remove_user(c, callback, 0, 0);
		}
	}

	options_write("options");
	cache_quit();
	fetch_quit();

	return 0;
}

void gui_multitask(void)
{
/* 	putchar('-'); */
}

#ifndef riscos
int stricmp(char *s0, char *s1)
{
	return strcasecmp(s0, s1);
}
#endif

void gui_remove_gadget(void *p)
{
}

#ifdef WITH_PLUGIN
void plugin_decode(void *a, void *b, void *c, void *d)
{
}
#endif

void html_redraw(struct content *c, long x, long y,
		unsigned long width, unsigned long height,
		long x0, long y0, long x1, long y1,
		float scale)
{
}

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)
{
}

#ifdef WITH_AUTH
void *login_list_get(char *url)
{
	return 0;
}
#endif

#ifdef WITH_PLUGIN
bool plugin_handleable(const char *mime_type)
{
	return false;
}
#endif

#ifdef riscos
#ifdef WITH_PLUGIN
void plugin_msg_parse(wimp_message *message, int ack) {}
void plugin_create(struct content *c) {}
void plugin_process_data(struct content *c, char *data, unsigned long size) {}
int plugin_convert(struct content *c, unsigned int width, unsigned int height) {}
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,
		long clip_x0, long clip_y0, long clip_x1, long clip_y1) {}
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) {}
#endif

char *NETSURF_DIR = "<NetSurf$Dir>";
#endif

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);
}

bool option_filter_sprites = false;
bool option_dither_sprites = false;

void die(const char *error)
{
	printf("die: %s\n", error);
	exit(1);
}

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;
}

void warn_user(const char *warn)
{
	printf("WARNING: %s\n", warn);
}