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.
37 #define MICROSOFTCOM_URL "http://www.microsoft.com/WindowsXP/pro/downloads/servicepacks/sp1/checkedbuild.asp"
40 GList * /* of (GnomeVFSURI *) */ mod_uri_microsoftcom_list(void)
49 if (GNOME_VFS_OK!=gnome_vfs_read_entire_file(MICROSOFTCOM_URL,&base_size,&base_contents)
51 g_warning(_("Cannot load base URL: %s"),MICROSOFTCOM_URL);
52 goto fail_free_base_contents;
54 base_contents[base_size-1]=0; /* string terminator */
55 if (!(href=strstr(base_contents,"http://download.microsoft.com/")) || !(href_end=strchr(href,'"'))) {
56 g_warning(_("Destination file URL not found in base URL: %s"),MICROSOFTCOM_URL);
57 goto fail_free_base_contents;
60 if (strncmp(href,"http://",strlen("http://"))) {
61 g_warning(_("Destination file URL not valid: %s"),href);
62 goto fail_free_base_contents;
64 href2=captive_printf_alloca("httpcaptive://%s",href+strlen("http://"));
65 if (!(uri=gnome_vfs_uri_new(href2))) {
66 g_warning(_("Found destination file URL not parsable: %s"),href2);
67 goto fail_free_base_contents;
69 g_free(base_contents);
70 return g_list_append(NULL,uri);
72 fail_free_base_contents:
73 g_free(base_contents);