2 * W32 modules finder from microsoft.com Internet download
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "microsoftcom.h" /* self */
23 #include <glib/gmessages.h>
24 #include <libgnomevfs/gnome-vfs-uri.h>
25 #include <libgnomevfs/gnome-vfs-result.h>
26 #include <libgnomevfs/gnome-vfs-utils.h>
29 #include <captive/macros.h>
33 /* Do we really need to use indirection by the following 'base' URL?
34 * It appears to me as if some Microsoft Service Pack files URLs
35 * have changed in the past.
36 * Currently we use fixed MICROSOFTDOWNLOAD_URL as we would have to
37 * implement custom Gnome-VFS http timeouts as 'ACQUIRE_CABINET_READ_RAW_READ_TIMEOUT'.
40 #define MICROSOFTCOM_URL "http://www.microsoft.com/WindowsXP/pro/downloads/servicepacks/sp1/checkedbuild.asp"
42 #define MICROSOFTDOWNLOAD_URL "http://download.microsoft.com/download/9/7/6/9763833d-bd58-41e2-9911-50f64c7252a3/xpsp1a_en_x86_CHK.exe"
46 GList * /* of (GnomeVFSURI *) */ mod_uri_microsoftcom_list(void)
48 #ifdef MICROSOFTCOM_URL
50 char *base_contents,*href_end;
55 #ifdef MICROSOFTCOM_URL
57 if (GNOME_VFS_OK!=gnome_vfs_read_entire_file(MICROSOFTCOM_URL,&base_size,&base_contents)
59 g_warning(_("Cannot load base URL: %s"),MICROSOFTCOM_URL);
60 goto fail_free_base_contents;
62 base_contents[base_size-1]=0; /* string terminator */
63 if (!(href=strstr(base_contents,"http://download.microsoft.com/")) || !(href_end=strchr(href,'"'))) {
64 g_warning(_("Destination file URL not found in base URL: %s"),MICROSOFTCOM_URL);
65 goto fail_free_base_contents;
69 href=MICROSOFTDOWNLOAD_URL;
71 if (!(uri=gnome_vfs_uri_new(href))) {
72 g_warning(_("Found destination file URL not parsable: %s"),href);
73 goto fail_free_base_contents;
75 #ifdef MICROSOFTCOM_URL
76 g_free(base_contents);
78 return g_list_append(NULL,uri);
80 fail_free_base_contents:
81 #ifdef MICROSOFTCOM_URL
82 g_free(base_contents);