|
@@ -291,48 +291,20 @@ int download_url ( char *url,
|
291
|
291
|
int ( * process ) ( unsigned char *data,
|
292
|
292
|
unsigned int blocknum,
|
293
|
293
|
unsigned int len, int eof ) ) {
|
294
|
|
- struct url_info url_info;
|
295
|
294
|
struct protocol *proto;
|
296
|
295
|
struct sockaddr_in server;
|
|
296
|
+ char *filename;
|
297
|
297
|
|
298
|
|
- DBG ( "Loading %s\n", url );
|
|
298
|
+ printf ( "Loading %s\n", url );
|
299
|
299
|
|
300
|
300
|
/* Parse URL */
|
301
|
|
- parse_url ( &url_info, url );
|
302
|
|
-
|
303
|
|
- /* Identify protocol */
|
304
|
|
- proto = identify_protocol ( url_info.protocol );
|
305
|
|
- if ( ! proto ) {
|
306
|
|
- if ( url_info.protocol ) {
|
307
|
|
- printf ( "Unknown protocol %s\n", url_info.protocol );
|
308
|
|
- } else {
|
309
|
|
- printf ( "No default protocols\n" );
|
310
|
|
- }
|
311
|
|
- goto error_out;
|
312
|
|
- }
|
313
|
|
-
|
314
|
|
- /* Resolve hostname */
|
315
|
|
- server.sin_addr = arptable[ARP_SERVER].ipaddr;
|
316
|
|
- if ( url_info.host ) {
|
317
|
|
- if ( ! resolv ( &server.sin_addr, url_info.host ) ) {
|
318
|
|
- printf ( "Cannot resolve host %s\n", url_info.host );
|
319
|
|
- goto error_out;
|
320
|
|
- }
|
|
301
|
+ if ( ! parse_url ( url, &proto, &server, &filename ) ) {
|
|
302
|
+ DBG ( "Unusable URL %s\n", url );
|
|
303
|
+ return 0;
|
321
|
304
|
}
|
322
|
|
-
|
323
|
|
- /* Resolve port number */
|
324
|
|
- server.sin_port = url_info.port ?
|
325
|
|
- strtoul ( url_info.port, NULL, 10 ) : 0;
|
326
|
|
-
|
327
|
|
- /* Restore URL */
|
328
|
|
- unparse_url ( &url_info );
|
329
|
|
-
|
|
305
|
+
|
330
|
306
|
/* Call protocol's method to download the file */
|
331
|
|
- return proto->load ( url, &server, url_info.file, process );
|
332
|
|
-
|
333
|
|
- error_out:
|
334
|
|
- unparse_url ( &url_info );
|
335
|
|
- return 0;
|
|
307
|
+ return proto->load ( url, &server, filename, process );
|
336
|
308
|
}
|
337
|
309
|
|
338
|
310
|
|