* Makefile.in (OBJS): Add setup_version.o.
(version.c): Rename to setup_version.
* choose.cc (set_action): Prevent NULL pointer dereference.
(package_sort): Remove.
* fromcwd.cc (canonicalize_version): Moved to version.cc.
(check_ini): New function for use with find to see if there is a cached setup.ini.
(do_fromcwd): Check for a cached setup.ini from any mirror site.
* ini.cc (find_routine): New function, for finding cached setup.ini's.
(do_local_ini): New function, drives parsing of local ini's.
(do_remote_ini): New function, drives parsing and caching of remote ini's.
(do_ini): Move guts to do_remote_ini and do_local_ini.
* list.h (removebyindex): New method.
* other.cc (save_dialog): Use new site_list and all_site_list to add the
new site to the site picklist.
(dialog_cmd): Only save the dialog when exiting the dialog.
* res.rc (IDD_SITE): Make IDC_URL_LIST a multiple-selection control.
* site.cc (site_list_type): Move to site.h
(site_list): New global, sites chosen by the user.
(all_site_list): New global, all potential sites.
(site_list_type::init): New method, parses a mirror.lst URL string into a
site_list_type object.
(site_list_type::site_list_type): New method.
(check_if_enable_next): Examine the control, not a local variable.
(load_dialog): Select all the user chosen sites by default.
(save_dialog): Adjust for multiple selection semantics.
(save_site_url): Save all user chosen sites.
(dialog_cmd): Don't save the dialog when the listbox recieves a message -
thats not needed.
Remove obsolete other_url reference.
(dialog_proc): Use all_site_list instead of site_list.
(site_sort): Remove.
(get_site_list): Remove malloc use - use list template instead.
Move site_list_type initialisation to site_list_type::init().
(get_initial_list_idx): Renamed to ...
(get_saved_sites): this. Also read in multiple sites to the site_list.
(do_site): Use all_site_list not site_list.
Log all chosen sites.
* site.h: New file, defines site related class, functions and variables.
* state.h: Add comment about use of state.h
(mirror_site): Remove.
(other_url): Remove.
(MIRROR_SITE): Remove.
* version.cc: New file, for version-handling and related functions.
+2001-12-04 Robert Collins <rbtcollins@hotmail.com>
+
+ * Makefile.in (OBJS): Add setup_version.o.
+ (version.c): Rename to setup_version.
+ * choose.cc (set_action): Prevent NULL pointer dereference.
+ (package_sort): Remove.
+ * fromcwd.cc (canonicalize_version): Moved to version.cc.
+ (check_ini): New function for use with find to see if there is a cached setup.ini.
+ (do_fromcwd): Check for a cached setup.ini from any mirror site.
+ * ini.cc (find_routine): New function, for finding cached setup.ini's.
+ (do_local_ini): New function, drives parsing of local ini's.
+ (do_remote_ini): New function, drives parsing and caching of remote ini's.
+ (do_ini): Move guts to do_remote_ini and do_local_ini.
+ * list.h (removebyindex): New method.
+ * other.cc (save_dialog): Use new site_list and all_site_list to add the
+ new site to the site picklist.
+ (dialog_cmd): Only save the dialog when exiting the dialog.
+ * res.rc (IDD_SITE): Make IDC_URL_LIST a multiple-selection control.
+ * site.cc (site_list_type): Move to site.h
+ (site_list): New global, sites chosen by the user.
+ (all_site_list): New global, all potential sites.
+ (site_list_type::init): New method, parses a mirror.lst URL string into a
+ site_list_type object.
+ (site_list_type::site_list_type): New method.
+ (check_if_enable_next): Examine the control, not a local variable.
+ (load_dialog): Select all the user chosen sites by default.
+ (save_dialog): Adjust for multiple selection semantics.
+ (save_site_url): Save all user chosen sites.
+ (dialog_cmd): Don't save the dialog when the listbox recieves a message -
+ thats not needed.
+ Remove obsolete other_url reference.
+ (dialog_proc): Use all_site_list instead of site_list.
+ (site_sort): Remove.
+ (get_site_list): Remove malloc use - use list template instead.
+ Move site_list_type initialisation to site_list_type::init().
+ (get_initial_list_idx): Renamed to ...
+ (get_saved_sites): this. Also read in multiple sites to the site_list.
+ (do_site): Use all_site_list not site_list.
+ Log all chosen sites.
+ * site.h: New file, defines site related class, functions and variables.
+ * state.h: Add comment about use of state.h
+ (mirror_site): Remove.
+ (other_url): Remove.
+ (MIRROR_SITE): Remove.
+ * version.cc: New file, for version-handling and related functions.
+
2001-12-02 Robert Collins <rbtcollins@hotmail.com>
* Makefile.in: Add filemanip.o to setup.
res.o \
rfc1738.o \
root.o \
+ setup_version.o \
simpsock.o \
site.o \
source.o \
$(BZ2LIB): $(bupdir)/bz2lib/Makefile
$(MAKE) -C $(@D) $(@F) CC="$(CC)" CFLAGS='$(MINGW_CFLAGS)'
-version.c : $(srcdir)/ChangeLog Makefile
+setup_version.c : $(srcdir)/ChangeLog Makefile
V=`grep '^\$$Revision.*' $(srcdir)/ChangeLog \
| sed -e 's/\$$Revision:* *//' \
-e 's/ *$$.*//'` ;\
echo "const char *version = \"$$V\";" > version.tmp ;\
- mv version.tmp version.c
+ mv version.tmp setup_version.c
%.o: %.rc
ifdef VERBOSE
/* are we currently on the radio button selection and installed */
if (pkg->desired == pkgtrustp (pkg, deftrust) && pkg->installed &&
(!pkg->desired || pkg->desired->binpicked)
- && (pkg->desired->src.Cached () || pkg->desired->src.sites.number ()))
+ && (pkg->desired &&
+ (pkg->desired->src.Cached () || pkg->desired->src.sites.number ())))
{
/* source only this file */
pkg->desired = pkg->installed;
find (".", scan2);
}
-int
-package_sort (const void *va, const void *vb)
-{
- packagemeta *a = (packagemeta *) va;
- packagemeta *b = (packagemeta *) vb;
- return strcasecmp (a->name, b->name);
-}
-
void
do_choose (HINSTANCE h)
{
#include "find.h"
#include "filemanip.h"
#include "version.h"
+#include "site.h"
+#include "rfc1738.h"
#include "port.h"
return (i >= 6) ? 1 : 0;
}
#endif
-char *
-canonicalize_version (const char *v)
-{
- static char nv[3][100];
- static int idx = 0;
- char *np;
- const char *dp;
- int i;
-
- idx = (idx + 1) % 3;
- np = nv[idx];
-
- while (*v)
- {
- if (isdigit (*v))
- {
- for (dp = v; *dp && isdigit (*dp); dp++);
- for (i = dp - v; i < 12; i++)
- *np++ = '0';
- while (v < dp)
- *np++ = *v++;
- }
- else
- *np++ = *v++;
- }
- *np++ = 0;
- return nv[idx];
-}
static void
found_file (char *path, unsigned int fsize)
#endif
}
+static bool found_ini;
+
+static void
+check_ini (char *path, unsigned int fsize)
+{
+ if (fsize && strstr (path, "setup.ini"))
+ found_ini = true;
+}
+
void
do_fromcwd (HINSTANCE h)
{
- if (_access ("./setup.ini", 0) == 0)
- {
- mirror_site = (char *) ".";
+ found_ini = true;
+ find (".", check_ini);
+ if (found_ini)
+ {
next_dialog = IDD_S_LOAD_INI;
return;
}
#include "log.h"
#include "version.h"
#include "mount.h"
+#include "site.h"
+#include "rfc1738.h"
+#include "find.h"
#include "io_stream.h"
static char *error_buf = 0;
static int error_count = 0;
-void
-do_ini (HINSTANCE h)
-{
- io_stream *ini_file = get_url_to_membuf (concat (MIRROR_SITE, "/setup.ini", 0));
- dismiss_url_status_dialog ();
+static int local_ini;
+static void
+find_routine (char *path, unsigned int fsize)
+{
+ if (!strstr (path, "/setup.ini") )
+ return;
+ io_stream *ini_file = io_stream::open (concat ("file://", local_dir,"/", path, 0), "rb");
if (!ini_file)
{
- note (IDS_SETUPINI_MISSING, MIRROR_SITE);
- next_dialog = IDD_SITE;
- return;
+ note (IDS_SETUPINI_MISSING, path);
+ return;
}
+ /* FIXME: only use most recent copy */
setup_timestamp = 0;
setup_version = 0;
- ini_init (ini_file, MIRROR_SITE);
+ ini_init (ini_file, concat ("file://", local_dir,"/", path, 0));
/*yydebug = 1; */
if (yyparse () || error_count > 0)
MessageBox (0, error_buf, error_count == 1 ? "Parse Error" : "Parse Errors", 0);
else
+ local_ini++;
+}
+
+static int
+do_local_ini ()
+{
+ local_ini = 0;
+ find (local_dir, find_routine);
+ return local_ini;
+}
+
+static int
+do_remote_ini ()
+{
+ size_t ini_count = 0;
+ for (size_t n = 1; n <= site_list.number (); n++)
{
- /* save known-good setup.ini locally */
- io_stream *inistream = io_stream::open ("file://setup.ini", "wb");
- if (inistream &&
- ! ini_file->seek (0, IO_SEEK_SET))
- {
- if (io_stream::copy (ini_file, inistream))
- io_stream::remove ("file://setup.ini");
- delete ini_file;
- delete inistream;
+ io_stream *ini_file =
+ get_url_to_membuf (concat (site_list[n]->url, "/setup.ini", 0));
+ dismiss_url_status_dialog ();
+
+ if (!ini_file)
+ {
+ note (IDS_SETUPINI_MISSING, site_list[n]->url);
+ continue;
}
+
+ /* FIXME: only use most recent copy */
+ setup_timestamp = 0;
+ setup_version = 0;
+
+ ini_init (ini_file, site_list[n]->url);
+
+ /*yydebug = 1; */
+
+ if (yyparse () || error_count > 0)
+ MessageBox (0, error_buf,
+ error_count == 1 ? "Parse Error" : "Parse Errors", 0);
+ else
+ {
+ /* save known-good setup.ini locally */
+ char const *fp = concat ("file://", local_dir, "/",
+ rfc1738_escape_part (site_list[n]->url),
+ "/setup.ini", 0);
+ io_stream::mkpath_p (PATH_TO_FILE, fp);
+ io_stream *inistream = io_stream::open (fp, "wb");
+ if (inistream && !ini_file->seek (0, IO_SEEK_SET))
+ {
+ if (io_stream::copy (ini_file, inistream))
+ io_stream::remove (fp);
+ delete ini_file;
+ delete inistream;
+ }
+ free ((void *) fp);
+ ini_count++;
+ }
+ }
+ return ini_count;
+}
+
+void
+do_ini (HINSTANCE h)
+{
+ size_t ini_count = 0;
+ if (source == IDC_SOURCE_CWD)
+ ini_count = do_local_ini ();
+ else
+ ini_count = do_remote_ini ();
+
+ if (ini_count == 0)
+ {
+ next_dialog = source == IDC_SOURCE_CWD ? IDD_S_FROM_CWD : IDD_SITE;
+ return;
}
if (get_root_dir ())
T & registerbykey (U);
/* add an element if one with the same key does not exist */
T & registerbyobject (T &);
+ /* remove by index */
+ T * removebyindex (size_t);
size_t number ()
{
return _number;
return *tempT;
}
+template < class T, class U, int Ucmp (U, U) >
+T * list < T, U, Ucmp >::removebyindex (size_t index)
+{
+ if (index && index <= _number)
+ {
+ T * rv = pointerblock[index - 1];
+ /* remove from index - 1 */
+ memmove (&pointerblock[index - 1], &pointerblock[index], (_number - index) * sizeof (T *));
+ _number --;
+ return rv;
+ }
+ return 0;
+}
+
#endif /* _LIST_H_ */
#include "state.h"
#include "msg.h"
#include "log.h"
+#include "site.h"
-/* private shared function, from site.cc */
-void save_site_url (void);
-
+static char * other_url = 0;
+
static void
check_if_enable_next (HWND h)
{
save_dialog (HWND h)
{
other_url = eget (h, IDC_OTHER_URL, other_url);
+ site_list_type *newsite = new site_list_type (other_url);
+ site_list_type &listobj = all_site_list.registerbyobject (*newsite);
+ if (&listobj != newsite)
+ /* That site was already registered */
+ delete newsite;
+ site_list.registerbyobject (listobj);
}
static BOOL
{
case IDC_OTHER_URL:
- save_dialog (h);
+ other_url = eget (h, IDC_OTHER_URL, other_url);
check_if_enable_next (h);
break;
FONT 8, "MS Sans Serif"
BEGIN
ICON IDI_CYGWIN,IDC_STATIC,5,5,20,20
- LTEXT "Select Download &Site",IDC_STATIC,55,5,135,11
+ LTEXT "Select Download &Sites",IDC_STATIC,55,5,135,11
LISTBOX IDC_URL_LIST,55,20,160,155,LBS_NOINTEGRALHEIGHT |
- WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
+ LBS_EXTENDEDSEL | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
DEFPUSHBUTTON "&Next -->",IDOK,105,185,45,15
PUSHBUTTON "Cancel",IDCANCEL,170,185,45,15
PUSHBUTTON "<-- &Back",IDC_BACK,60,185,45,15
#include "concat.h"
#include "log.h"
#include "io_stream.h"
+#include "site.h"
#include "port.h"
#define NO_IDX (-1)
#define OTHER_IDX (-2)
-class site_list_type
-{
-public:
- char *url;
- char *displayed_url;
- char *key;
-};
-
-static site_list_type *site_list = 0;
-static int list_idx = NO_IDX;
+list < site_list_type, const char *, strcasecmp > site_list;
+list < site_list_type, const char *, strcasecmp > all_site_list;
static int mirror_idx = NO_IDX;
+void
+site_list_type::init (char const *newurl)
+{
+ url = _strdup (newurl);
+ displayed_url = _strdup (newurl);
+ char *dot = strchr (displayed_url, '.');
+ if (dot)
+ {
+ dot = strchr (dot, '/');
+ if (dot)
+ *dot = 0;
+ }
+ key = (char *) malloc (2 * strlen (newurl) + 3);
+
+ dot = displayed_url;
+ dot += strlen (dot);
+ char *dp = key;
+ while (dot != displayed_url)
+ {
+ if (*dot == '.' || *dot == '/')
+ {
+ char *sp;
+ if (dot[3] == 0)
+ *dp++ = '~'; /* sort .com/.edu/.org together */
+ for (sp = dot + 1; *sp && *sp != '.' && *sp != '/';)
+ *dp++ = *sp++;
+ *dp++ = ' ';
+ }
+ dot--;
+ }
+ *dp++ = ' ';
+ strcpy (dp, displayed_url);
+}
+
+site_list_type::site_list_type (char const *newurl)
+{
+ init (newurl);
+}
+
static void
check_if_enable_next (HWND h)
{
- EnableWindow (GetDlgItem (h, IDOK), (mirror_idx != NO_IDX) ? 1 : 0);
+ EnableWindow (GetDlgItem (h, IDOK),
+ SendMessage (GetDlgItem (h, IDC_URL_LIST), LB_GETSELCOUNT, 0,
+ 0) > 0 ? 1 : 0);
}
static void
load_dialog (HWND h)
{
HWND listbox = GetDlgItem (h, IDC_URL_LIST);
- SendMessage (listbox, LB_SETCURSEL, list_idx, 0);
+ for (size_t n = 1; n <= site_list.number (); n++)
+ {
+ int index = SendMessage (listbox, LB_FINDSTRING, (WPARAM) - 1,
+ (LPARAM) site_list[n]->displayed_url);
+ if (index != LB_ERR)
+ SendMessage (listbox, LB_SELITEMRANGE, TRUE, (index << 16) | index);
+ }
check_if_enable_next (h);
}
save_dialog (HWND h)
{
HWND listbox = GetDlgItem (h, IDC_URL_LIST);
- list_idx = SendMessage (listbox, LB_GETCURSEL, 0, 0);
- if (list_idx == LB_ERR)
+ mirror_idx = 0;
+ while (site_list.number () > 0)
+ /* we don't delete the object because it's stored in the all_site_list. */
+ site_list.removebyindex (1);
+ int sel_count = SendMessage (listbox, LB_GETSELCOUNT, 0, 0);
+ if (sel_count > 0)
{
- mirror_site = 0;
- mirror_idx = NO_IDX;
- list_idx = NO_IDX;
+ int sel_buffer[sel_count];
+ int sel_count2 = SendMessage (listbox, LB_GETSELITEMS, sel_count,
+ (LPARAM) sel_buffer);
+ if (sel_count != sel_count2)
+ {
+ NEXT (IDD_SITE);
+ }
+ for (int n = 0; n < sel_count; n++)
+ {
+ int mirror =
+ SendMessage (listbox, LB_GETITEMDATA, sel_buffer[n], 0);
+ if (mirror == OTHER_IDX)
+ mirror_idx = OTHER_IDX;
+ else
+ site_list.registerbyobject (*all_site_list[mirror]);
+ }
}
else
{
- mirror_idx = SendMessage (listbox, LB_GETITEMDATA, list_idx, 0);
- if (mirror_idx == OTHER_IDX)
- mirror_site = 0;
- else
- mirror_site = site_list[mirror_idx].url;
+ NEXT (IDD_SITE);
}
}
void
save_site_url ()
{
- if (!MIRROR_SITE)
- return;
-
io_stream *f = io_stream::open ("cygfile:///etc/setup/last-mirror", "wb");
- if (f)
+ for (size_t n = 1; n <= site_list.number (); n++)
{
- char temp[_MAX_PATH];
- /* TODO: potential buffer overflow. we need snprintf asap. */
- sprintf (temp, "%s\n", MIRROR_SITE);
- f->write (temp, strlen (temp));
- delete f;
+ if (f)
+ {
+ char temp[_MAX_PATH];
+ /* TODO: potential buffer overflow. we need snprintf asap. */
+ // FIXME: write all selected sites
+ sprintf (temp, "%s\n", site_list[n]->url);
+ f->write (temp, strlen (temp));
+ }
}
+ delete f;
}
static BOOL
{
case IDC_URL_LIST:
- save_dialog (h);
check_if_enable_next (h);
break;
NEXT (IDD_OTHER_URL);
else
{
- other_url = 0;
save_site_url ();
NEXT (IDD_S_LOAD_INI);
}
static BOOL CALLBACK
dialog_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
{
- int i, j;
+ int j;
HWND listbox;
switch (message)
{
case WM_INITDIALOG:
listbox = GetDlgItem (h, IDC_URL_LIST);
- for (i = 0; site_list[i].url; i++)
+ for (size_t i = 1; i <= all_site_list.number (); i++)
{
j =
SendMessage (listbox, LB_ADDSTRING, 0,
- (LPARAM) site_list[i].displayed_url);
+ (LPARAM) all_site_list[i]->displayed_url);
SendMessage (listbox, LB_SETITEMDATA, j, i);
}
j = SendMessage (listbox, LB_ADDSTRING, 0, (LPARAM) "Other URL");
return FALSE;
}
-static int
-site_sort (const void *va, const void *vb)
-{
- site_list_type *a = (site_list_type *) va;
- site_list_type *b = (site_list_type *) vb;
- return strcmp (a->key, b->key);
-}
-
static int
get_site_list (HINSTANCE h)
{
char *bol, *eol, *nl;
-
- /* null plus account for possibly missing NL plus account for "Other
- URL" from previous run. */
- int nmirrors = 3;
-
- for (bol = mirrors; *bol; bol++)
- if (*bol == '\n')
- nmirrors++;
-
- site_list = (site_list_type *) malloc (nmirrors * sizeof (site_list_type));
- nmirrors = 0;
-
nl = mirrors;
while (*nl)
{
char *semi = strchr (bol, ';');
if (semi)
*semi = 0;
- site_list[nmirrors].url = _strdup (bol);
- site_list[nmirrors].displayed_url = _strdup (bol);
- char *dot = strchr (site_list[nmirrors].displayed_url, '.');
- if (dot)
- {
- dot = strchr (dot, '/');
- if (dot)
- *dot = 0;
- }
- site_list[nmirrors].key =
- (char *) malloc (2 * strlen (bol) + 3);
-
- dot = site_list[nmirrors].displayed_url;
- dot += strlen (dot);
- char *dp = site_list[nmirrors].key;
- while (dot != site_list[nmirrors].displayed_url)
- {
- if (*dot == '.' || *dot == '/')
- {
- char *sp;
- if (dot[3] == 0)
- *dp++ = '~'; /* sort .com/.edu/.org together */
- for (sp = dot + 1; *sp && *sp != '.' && *sp != '/';)
- *dp++ = *sp++;
- *dp++ = ' ';
- }
- dot--;
- }
- *dp++ = ' ';
- strcpy (dp, site_list[nmirrors].displayed_url);
-
- nmirrors++;
+ site_list_type *newsite = new site_list_type (bol);
+ site_list_type & listobj =
+ all_site_list.registerbyobject (*newsite);
+ if (&listobj != newsite)
+ /* That site was already registered */
+ delete newsite;
}
}
- site_list[nmirrors].url = 0;
- delete[] mirrors;
-
- qsort (site_list, nmirrors, sizeof (site_list_type), site_sort);
+ delete[]mirrors;
return 0;
}
#define NOSAVE3_LEN (sizeof ("ftp://gcc.gnu.org/") - 1)
static void
-get_initial_list_idx ()
+get_saved_sites ()
{
io_stream *f = io_stream::open ("cygfile:///etc/setup/last-mirror", "rt");
if (!f)
return;
char site[1000];
- char *fg_ret = f->gets (site, 1000);
- delete f;
- if (!fg_ret)
- return;
+ char *fg_ret;
+ while ((fg_ret = f->gets (site, 1000)))
+ {
- char *eos = site + strlen (site) - 1;
- while (eos >= site && (*eos == '\n' || *eos == '\r'))
- *eos-- = '\0';
+ char *eos = site + strlen (site) - 1;
+ while (eos >= site && (*eos == '\n' || *eos == '\r'))
+ *eos-- = '\0';
- if (eos < site)
- return;
+ if (eos < site)
+ continue;
- int i;
- for (i = 0; site_list[i].url; i++)
- if (strcmp (site_list[i].url, site) == 0)
- break;
+ bool found = false;
+ for (size_t i = 1; !found && i <= all_site_list.number (); i++)
+ if (!strcasecmp (site, all_site_list[i]->url))
+ found = true;
- if (!site_list[i].url)
- {
- /* Don't default to certain machines ever since they suffer
- from bandwidth limitations. */
- if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) == 0
- || strnicmp (site, NOSAVE2, NOSAVE2_LEN) == 0
- || strnicmp (site, NOSAVE3, NOSAVE3_LEN) == 0)
- return;
- site_list[i].displayed_url = site_list[i].url = _strdup (site);
- site_list[i + 1].url = 0;
+ if (!found)
+ {
+ /* Don't default to certain machines ever since they suffer
+ from bandwidth limitations. */
+ if (strnicmp (site, NOSAVE1, NOSAVE1_LEN) == 0
+ || strnicmp (site, NOSAVE2, NOSAVE2_LEN) == 0
+ || strnicmp (site, NOSAVE3, NOSAVE3_LEN) == 0)
+ return;
+ site_list_type *newsite = new site_list_type (site);
+ site_list_type & listobj =
+ all_site_list.registerbyobject (*newsite);
+ if (&listobj != newsite)
+ /* That site was already registered - shouldn't happen, but safety first */
+ delete newsite;
+ }
+ /* TODO: make a site_type method to create a serach key on-the-fly from a
+ URL
+ */
+ found = false;
+ for (size_t i = 1; !found && i <= all_site_list.number (); i++)
+ if (!strcasecmp (site, all_site_list[i]->url))
+ site_list.registerbyobject (*all_site_list[i]);
}
+ delete f;
- mirror_idx = list_idx = i;
}
void
{
int rv = 0;
- if (site_list == 0)
+ if (all_site_list.number () == 0)
if (get_site_list (h))
{
NEXT (IDD_NET);
return;
}
- get_initial_list_idx ();
+ get_saved_sites ();
rv = DialogBox (h, MAKEINTRESOURCE (IDD_SITE), 0, dialog_proc);
if (rv == -1)
fatal (IDS_DIALOG_FAILED);
- if (mirror_idx != OTHER_IDX)
- log (0, "site: %s", mirror_site);
+ for (size_t n = 1; n <= site_list.number (); n++)
+ log (0, "site: %s", site_list[n]->url);
}
--- /dev/null
+/*
+ * Copyright (c) 2001, Robert Collins.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by Robert Collins <rbtcollins@hotmail.com>
+ *
+ */
+
+#ifndef _SITE_H_
+#define _SITE_H_
+
+/* required to parse this file */
+#include <strings.h>
+#include "list.h"
+
+class site_list_type
+{
+public:
+ site_list_type () : url(0), displayed_url (0), key (0) {};
+ site_list_type (char const *);
+ /* workaround for missing placement new in gcc 2.95 */
+ void init (char const *);
+ ~site_list_type ()
+ {
+ if (url)
+ free (url);
+ if (displayed_url)
+ free (displayed_url);
+ if (key)
+ free (key);
+ };
+ char *url;
+ char *displayed_url;
+ char *key;
+};
+
+/* user chosen sites */
+extern list <site_list_type, const char *, strcasecmp> site_list;
+/* potential sites */
+extern list <site_list_type, const char *, strcasecmp> all_site_list;
+
+void save_site_url ();
+
+#endif /* _SITE_H_ */
/* The purpose of this file is to contain all the global variables
that define the "state" of the install, that is, all the
information that the user has provided so far. These are set by
- the various dialogs and used by the various actions. */
+ the various dialogs and used by the various actions.
+
+ Note that this is deprecated. Persistent settings should be accessed
+ via a class that stores them cross-installs, and non-persistent settings
+ directly via the appropriate class. One of the reasons for this is that
+ non-trivial types would require this file to include appropriate headers,
+ making all of setup.exe rebuild for potentially minor changes.
+
+ */
extern int source;
extern char *net_ftp_user;
extern char *net_ftp_passwd;
-extern char *mirror_site;
-extern char *other_url;
-
extern int trust_level;
-
-#define MIRROR_SITE (mirror_site ? mirror_site : other_url)
--- /dev/null
+/*
+ * Copyright (c) 2000, Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * A copy of the GNU General Public License can be found at
+ * http://www.gnu.org/
+ *
+ * Written by DJ Delorie <dj@cygnus.com>
+ *
+ */
+
+#if 0
+static const char *cvsid =
+ "\n%%% $Id$\n";
+#endif
+
+#include "win32.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.h>
+
+#include "port.h"
+char *
+canonicalize_version (const char *v)
+{
+ static char nv[3][100];
+ static int idx = 0;
+ char *np;
+ const char *dp;
+ int i;
+
+ idx = (idx + 1) % 3;
+ np = nv[idx];
+
+ while (*v)
+ {
+ if (isdigit (*v))
+ {
+ for (dp = v; *dp && isdigit (*dp); dp++);
+ for (i = dp - v; i < 12; i++)
+ *np++ = '0';
+ while (v < dp)
+ *np++ = *v++;
+ }
+ else
+ *np++ = *v++;
+ }
+ *np++ = 0;
+ return nv[idx];
+}