* Makefile.in (OBJS): Remove category_list - it's not needed.
* README: More wishlist updates.
* category.cc (Category::Category): Initialise new members.
(Categorycmp): New function.
* category.h (Category): New member key for template use.
* category_list.cc: Remove.
* category_list.h: Remove.
(Categorycmp): New function prototype.
* choose.cc: Remove category_list - not needed.
(set_action): Only show the 'source' option when the source is actually
available.
(add_required): Fix recursion limiter to 5.
(fill_missing_category): Use list access.
(default_trust): Ditto.
(pick_line::paint): Ditto.
(_view::init_headers): Ditto.
(_view::insert_pkg): Ditto.
(_view::insert_category): Ditto.
(_view::click): Ditto.
(set_view_mode): Ditto.
(do_choose): Ditto.
* cygpackage.h: Remove category_list - not needed.
* geturl.cc (get_url_to_string): Fix null byte insertion.
* inipatse.y: Remove category_list - not needed.
(categories): Use list access.
* package_db.cc: Ditto.
* package_db.h: Remove category_list - not needed.
(packagedb): Use the list template for categories.
* package_meta.cc (add_category): Ditto.
* package_meta.h (CategoryPackage): Link to the category as well.
(packagemeta): Use a list of CategoryPackages instead of Categories
for more memory efficient cross-referencing.
+2001-11-30 Robert Collins <rbtcollins@hotmail.com>
+
+ * Makefile.in (OBJS): Remove category_list - it's not needed.
+ * README: More wishlist updates.
+ * category.cc (Category::Category): Initialise new members.
+ (Categorycmp): New function.
+ * category.h (Category): New member key for template use.
+ * category_list.cc: Remove.
+ * category_list.h: Remove.
+ (Categorycmp): New function prototype.
+ * choose.cc: Remove category_list - not needed.
+ (set_action): Only show the 'source' option when the source is actually
+ available.
+ (add_required): Fix recursion limiter to 5.
+ (fill_missing_category): Use list access.
+ (default_trust): Ditto.
+ (pick_line::paint): Ditto.
+ (_view::init_headers): Ditto.
+ (_view::insert_pkg): Ditto.
+ (_view::insert_category): Ditto.
+ (_view::click): Ditto.
+ (set_view_mode): Ditto.
+ (do_choose): Ditto.
+ * cygpackage.h: Remove category_list - not needed.
+ * geturl.cc (get_url_to_string): Fix null byte insertion.
+ * inipatse.y: Remove category_list - not needed.
+ (categories): Use list access.
+ * package_db.cc: Ditto.
+ * package_db.h: Remove category_list - not needed.
+ (packagedb): Use the list template for categories.
+ * package_meta.cc (add_category): Ditto.
+ * package_meta.h (CategoryPackage): Link to the category as well.
+ (packagemeta): Use a list of CategoryPackages instead of Categories
+ for more memory efficient cross-referencing.
+
2001-11-30 Robert Collins <rbtcollins@hotmail.com>
* package_db.cc (packagedb::flush): Write a canonical version for all packages
archive_tar_file.o \
autoload.o \
category.o \
- category_list.o \
choose.o \
compress.o \
compress_bz.o \
TODO:
* Src tickbox /source only can be confusing.
-* file magic detection.
+* file magic detection. - partially complete.
* support rpm/deb files for reading the package from. (To allow the maintainers the use of rpm/deb tools to create packages.)
* make a librar(y|ies) for setup and cygcheck to use containing
1) Something to translate POSIX -> native. Currently called "cygpath"
4) Something to parse a tar file name into package/version or altenatively,
return that information from 2)
5) Something to return a list of files associated with a package.
-* Make skip only ever appear for non-installed packages.
-
-
+* When installing and enough packages default to visible, te RH scrollbar is
+ sometimes hidden.
+
+
WISHLIST:
* rsync:// support
* Some way to download *all* the source
* When clicking on a category that is showing a partial list (auto added items due to dependencies) show the full list rather than minising.
* continue downloading past errors, present log of failures at end
- * skip sould be followed by the <prec/curr/exp> from the radio buttons, not by prev.
* incremental/recoverable download capability.
* build-depends
* FTP control connections should be closed when we are awaiting user input.
* View mdoe caption on the right hand of the screen
* Downloading from the internet should allow redownloading already present files. (This
happens via the reinstall/redo already - perhaps this is "done".)
+ * Make skip only ever appear for non-installed packages.
+ * skip sould be followed by the <prec/curr/exp> from the radio buttons, not by prev.
/* normal members */
-Category::Category ():next (0), name (0), packages (0)
+Category::Category ():next (0), name (0), key (0), packages (0)
{
}
{
/* FIXME: search the global category list for name, and reuse that pointer */
name = strdup (categoryname);
+ key = name;
+}
+
+int
+Categorycmp (Category & a, Category & b)
+{
+ return strcasecmp (a.name, b.name);
}
Category *next; /* the next category in the list */
const char *name; /* the category */
+ const char *key; /* always == name */
CategoryPackage *packages; /* the packages in this category */
};
+int Categorycmp (Category &, Category &);
#endif /* _CATEGORY_H_ */
+++ /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>
- *
- */
-
-/* categories for packages */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "category_list.h"
-#include "category.h"
-
-CategoryList::CategoryList ():_categories (0), ncategories (0),
-categoriesspace (0)
-{
-}
-
-Category & CategoryList::register_category (const char *catname)
-{
- Category *
- tempcat =
- getcategorybyname (catname);
- if (!tempcat)
- {
- if (ncategories == categoriesspace)
- {
- Category **
- newcategories = (Category **)
- realloc (_categories,
- sizeof (Category *) * (categoriesspace + 20));
- if (!newcategories)
- {
- //die
- exit (100);
- }
- _categories = newcategories;
- if (categoriesspace == 0)
- _categories[0] = 0;
- categoriesspace += 20;
- }
- tempcat = new Category (catname);
- size_t n;
- for (n = 0;
- n < ncategories
- && strcasecmp (_categories[n]->name, tempcat->name) < 0; n++);
- /* insert at n */
- if (n)
- _categories[n - 1]->next = tempcat;
- if (n < ncategories)
- tempcat->next = _categories[n];
- memmove (&_categories[n + 1], &_categories[n],
- (ncategories - n) * sizeof (Category *));
- _categories[n] = tempcat;
- ncategories++;
- }
- return *tempcat;
-}
-
-Category *
-CategoryList::getcategorybyname (const char *name)
-{
- for (size_t n = 0; n < ncategories; n++)
- if (strcasecmp (_categories[n]->name, name) == 0)
- return _categories[n];
- return 0;
-}
+++ /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>
- *
- */
-
-/* a list categories for packages */
-
-#ifndef _CATEGORY_LIST_H_
-#define _CATEGORY_LIST_H_
-
-class Category;
-
-class CategoryList
-{
-public:
- Category & register_category (const char *name);
- Category *getcategorybyname (const char *name);
- int categories ()
- {
- return ncategories;
- };
- Category *getfirstcategory ()
- {
- return *_categories;
- };
- CategoryList ();
-private:
- Category ** _categories;
- size_t ncategories;
- size_t categoriesspace;
-};
-
-
-#endif /* _CATEGORY_LIST_H_ */
#include "io_stream.h"
#include "choose.h"
#include "category.h"
-#include "category_list.h"
#include "package_db.h"
#include "package_meta.h"
{0, 0, 0, 0}
};
-static int add_required (packagemeta & pkg, size_t depth=0);
+static int add_required (packagemeta & pkg, size_t depth = 0);
static void set_view_mode (HWND h, views mode);
#define pkgtrustp(pkg,t) (packageversion *)(t==TRUST_PREV ? pkg->prev : t == TRUST_CURR ? pkg->curr : pkg->exp)
}
/* 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 || pkg->desired->binpicked)
+ && (pkg->desired->src.Cached () || pkg->desired->src.sites.number ()))
{
- /* FIXME: is source available */
/* source only this file */
pkg->desired = pkg->installed;
pkg->desired->binpicked = 0;
dp = pkg.desired->required;
packagedb db;
/* cheap test for too much recursion */
- if (depth > db.npackages ())
+ if (depth > 5)
return 0;
while (dp)
{
packagedb db;
for (packagemeta * pkg = db.getfirstpackage (); pkg;
pkg = db.getnextpackage ())
- if (!pkg->Categories ().categories ())
- pkg->add_category (db.categories.register_category ("Misc"));
+ if (!pkg->Categories.number ())
+ pkg->add_category (db.categories.registerbykey ("Misc"));
}
static void
for (packagemeta * pkg = db.getfirstpackage (); pkg;
pkg = db.getnextpackage ())
{
- if (pkg->installed || pkg->Categories ().getcategorybyname ("Base")
- || pkg->Categories ().getcategorybyname ("Misc"))
+ if (pkg->installed
+ || pkg->Categories.getbykey (db.categories.registerbykey ("Base"))
+ || pkg->Categories.getbykey (db.categories.registerbykey ("Misc")))
{
pkg->desired = pkgtrustp (pkg, trust);
if (pkg->desired)
bitmap_dc, 0, 0, SRCCOPY);
/* shows "first" category - do we want to show any? */
- if (pkg->Categories ().getfirstcategory () && show_cat)
+ if (pkg->Categories.number () && show_cat)
TextOut (hdc, x + chooser->headers[chooser->cat_col].x, r,
- pkg->Categories ().getfirstcategory ()->name,
- strlen (pkg->Categories ().getfirstcategory ()->name));
+ pkg->Categories.getnth (1)->key.name,
+ strlen (pkg->Categories.getnth (1)->key.name));
if (!pkg->SDesc ())
s = pkg->name;
note_width (headers, dc,
pkg->versions.getnth (n)->Canonical_version (),
NEW_COL_SIZE_SLOP, new_col);
- for (Category * cat = db.categories.getfirstcategory (); cat;
- cat = cat->next)
- note_width (headers, dc, cat->name, 0, cat_col);
+ for (size_t n = 1; n <= db.categories.number (); n++)
+ note_width (headers, dc, db.categories.getnth (n)->name, 0, cat_col);
if (!pkg->SDesc ())
note_width (headers, dc, pkg->name, 0, pkg_col);
else
{
lines =
(pick_line *) calloc (db.npackages () +
- db.categories.categories (),
+ db.categories.number (),
sizeof (pick_line));
nlines = 0;
insert_at (0, line);
else
{
// assert (lines); /* protect against a coding change in future */
- for (Category * cat = pkg.Categories ().getfirstcategory (); cat;
- cat = cat->next)
+ for (size_t x = 1; x <= pkg.Categories.number (); x++)
{
+ Category & cat = pkg.Categories.getnth (x)->key;
/* insert the package under this category in the list. If this category is not
visible, add it */
int n = 0;
{
/* this should be a generic call to list_sort_cmp */
if (lines[n].get_category ()
- && cat->name == lines[n].get_category ()->name)
+ && !strcasecmp (cat.name, lines[n].get_category ()->name))
{
insert_under (n, line);
n = nlines;
if (n == nlines)
{
/* the category wasn't visible - insert at the end */
- insert_category (cat, CATEGORY_COLLAPSED);
+ insert_category (&cat, CATEGORY_COLLAPSED);
insert_pkg (pkg);
}
}
{
packagedb db;
lines =
- (pick_line *) malloc ((db.npackages () + db.categories.categories ())
+ (pick_line *) malloc ((db.npackages () + db.categories.number ())
* sizeof (pick_line));
memset (lines, '\0',
(db.npackages () +
- db.categories.categories ()) * sizeof (pick_line));
+ db.categories.number ()) * sizeof (pick_line));
nlines = 0;
insert_at (0, line);
if (!collapsed)
for (CategoryPackage * catpkg = cat->packages; catpkg;
catpkg = catpkg->next)
- insert_pkg (catpkg->pkg);
+ insert_pkg (*catpkg->pkg);
}
else
{
if (!collapsed)
for (CategoryPackage * catpkg = cat->packages; catpkg;
catpkg = catpkg->next)
- insert_pkg (catpkg->pkg);
+ insert_pkg (*catpkg->pkg);
n = nlines;
}
else if (lines[n].get_category () == cat)
if (!collapsed)
for (CategoryPackage * catpkg = cat->packages; catpkg;
catpkg = catpkg->next)
- insert_pkg (catpkg->pkg);
+ insert_pkg (*catpkg->pkg);
}
}
}
lines[row].get_category ()->packages; catpkg;
catpkg = catpkg->next)
{
- packagemeta & pkg = catpkg->pkg;
+ packagemeta & pkg = *catpkg->pkg;
int n = row + 1;
pick_line line;
line.set_line (&pkg);
case VIEW_PACKAGE:
for (packagemeta * pkg = db.getfirstpackage (); pkg;
pkg = db.getnextpackage ())
- if ((!pkg->desired && pkg->installed) || (pkg->desired && (pkg->desired->srcpicked
- || pkg->desired->binpicked)))
+ if ((!pkg->desired && pkg->installed)
+ || (pkg->desired
+ && (pkg->desired->srcpicked || pkg->desired->binpicked)))
chooser->insert_pkg (*pkg);
break;
case VIEW_PACKAGE_FULL:
break;
case VIEW_CATEGORY:
/* start collapsed. TODO: make this a chooser flag */
- for (Category * cat = db.categories.getfirstcategory (); cat;
- cat = cat->next)
- chooser->insert_category (cat, CATEGORY_COLLAPSED);
+ for (size_t n = 1; n <= db.categories.number (); n++)
+ chooser->insert_category (db.categories.getnth (n),
+ CATEGORY_COLLAPSED);
break;
default:
break;
" src?=%s",
pkg->name, action, trust, installed,
pkg->desired && pkg->desired->srcpicked ? "yes" : "no");
- if (pkg->Categories ().categories ())
+ if (pkg->Categories.number ())
{
/* List categories the package belongs to */
int categories_len = 0;
- Category *cp;
- for (cp = pkg->Categories ().getfirstcategory (); cp; cp = cp->next)
- if (cp->name)
- categories_len += strlen (cp->name) + 2;
+ for (size_t n = 1; n <= pkg->Categories.number (); n++)
+ categories_len +=
+ strlen (pkg->Categories.getnth (n)->key.name) + 2;
if (categories_len > 0)
{
char *categories = (char *) malloc (categories_len);
- strcpy (categories,
- pkg->Categories ().getfirstcategory ()->name);
- for (cp = pkg->Categories ().getfirstcategory ()->next; cp;
- cp = cp->next)
- if (cp->name)
- {
- strcat (categories, ", ");
- strcat (categories, cp->name);
- }
+ strcpy (categories, pkg->Categories.getnth (1)->key.name);
+ for (size_t n = 2; n <= pkg->Categories.number (); n++)
+ {
+ strcat (categories, ", ");
+ strcat (categories, pkg->Categories.getnth (n)->key.name);
+ }
log (LOG_BABBLE, " categories=%s", categories);
free (categories);
}
#ifndef _CYGPACKAGE_H_
#define _CYGPACKAGE_H_
-#include "category_list.h"
-
class cygpackage:public packageversion
{
public:
if (n->file_size)
max_bytes = n->file_size;
- io_stream_memory * membuf = new io_stream_memory ();
-
+ io_stream_memory *membuf = new io_stream_memory ();
+
int total_bytes = 1; /* for the NUL terminator */
progress (0);
while (1)
{
char buf[2048];
- ssize_t rlen,wlen;
+ ssize_t rlen, wlen;
rlen = n->read (buf, 2048);
if (rlen > 0)
- {
- wlen = membuf->write (buf, rlen);
- if (wlen != rlen)
- /* FIXME: Show an error message */
- break;
- total_bytes += rlen;
- progress (total_bytes);
- }
+ {
+ wlen = membuf->write (buf, rlen);
+ if (wlen != rlen)
+ /* FIXME: Show an error message */
+ break;
+ total_bytes += rlen;
+ progress (total_bytes);
+ }
else
break;
}
log (LOG_BABBLE, "get_url_to_string(): malloc failed for rv!");
return 0;
}
-
+
ssize_t rlen;
- rlen = membuf->read (rv, total_bytes);
- rv [total_bytes] = '\0';
+ rlen = membuf->read (rv, total_bytes - 1);
+ rv[total_bytes - 1] = '\0';
if (n)
delete n;
if (membuf)
#include "win32.h"
#include "package_db.h"
#include "category.h"
-#include "category_list.h"
#include "ini.h"
#include "iniparse.h"
#include "filemanip.h"
;
categories
- : STRING { cp->add_category (db.categories.register_category ($1));
+ : STRING { cp->add_category (db.categories.registerbykey ($1));
} categories
- | STRING { cp->add_category (db.categories.register_category ($1)); }
+ | STRING { cp->add_category (db.categories.registerbykey ($1)); }
;
%%
packagemeta **
packagedb::packages =
0;
-size_t
- packagedb::packagecount =
- 0;
-size_t
- packagedb::packagespace =
- 0;
+size_t packagedb::packagecount = 0;
+size_t packagedb::packagespace = 0;
int
packagedb::installeddbread =
0;
-CategoryList
- packagedb::categories =
- CategoryList ();
+list < Category, char const *,
+ strcasecmp >
+ packagedb::categories;
#ifndef _PACKAGE_DB_H_
#define _PACKAGE_DB_H_
-class CategoryList;
+/* required to parse this file */
+#include "list.h"
+//class CategoryList;
+class Category;
class packagemeta;
class io_stream;
return packagecount;
};
/* all seen categories */
- static CategoryList categories;
+ static list < Category, char const *, strcasecmp > categories;
private:
/* this gets sorted */
static packagemeta **packages;
packagemeta::add_category (Category & cat)
{
/* add a new record for the package list */
- /* TODO: alpabetical inserts ? */
- categories.register_category (cat.name);
-
- CategoryPackage *templink = new CategoryPackage (*this);
- /* tell the category we are linking from we exist */
- templink->next = cat.packages;
- cat.packages = templink;
+ CategoryPackage & catpack = Categories.registerbykey (cat);
+ catpack.pkg = this;
}
char const *
class packageversion;
class packagemeta;
+class category;
/* Required to parse this completely */
-#include "category_list.h"
#include "list.h"
#include "strings.h"
+#include "category.h"
/*
For cleanliness this may need to be put in its own file later. */
class CategoryPackage
{
public:
- CategoryPackage (packagemeta & package):next (0), pkg (package)
+ CategoryPackage (Category & cat):key (cat), pkg (0)
{
+ next = cat.packages;
+ cat.packages = this;
};
+ Category & key;
CategoryPackage *next; /* The next package pointer in the list */
- packagemeta & pkg;
+ packagemeta *pkg;
};
/* what categories does this package belong in. Note that if multiple versions
* of a package disagree.... the first one read in will take precedence.
*/
- CategoryList & Categories ()
- {
- return categories;
- };
- /* Add a known category to this objects category list.
- */
void add_category (Category &);
+ list < CategoryPackage, Category &, Categorycmp > Categories;
list < packageversion, char const *, strcasecmp > versions;
/* which one is installed. */
/* Now for the user stuff :] */
/* What version does the user want ? */
packageversion *desired;
-private:
- CategoryList categories;
};
#endif /* _PACKAGE_META_H_ */