]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
2001-11-30 Robert Collins <rbtcollins@hotmail.com>
authorRobert Collins <rbtcollins@hotmail.com>
Fri, 30 Nov 2001 12:25:00 +0000 (12:25 +0000)
committerRobert Collins <rbtcollins@hotmail.com>
Fri, 30 Nov 2001 12:25:00 +0000 (12:25 +0000)
        * 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.

15 files changed:
ChangeLog
Makefile.in
README
category.cc
category.h
category_list.cc [deleted file]
category_list.h [deleted file]
choose.cc
cygpackage.h
geturl.cc
iniparse.y
package_db.cc
package_db.h
package_meta.cc
package_meta.h

index 844b872e48b9870294e021357248772b82999aee..e5b0ccf8cb147ecfcd4435d1f38499be2ddce372 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+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
index 9ce84a09a1e127a7f837f3448fac4428de54e87e..99171f10a13601611b7f76a0bd12cd4ad552fc1f 100644 (file)
@@ -85,7 +85,6 @@ OBJS = \
        archive_tar_file.o \
        autoload.o \
        category.o \
-       category_list.o \
        choose.o \
        compress.o \
        compress_bz.o \
diff --git a/README b/README
index a7d64b35996b2b7d6b1aa74ed229c135f4c72d26..ff2e3dc55466dc9b514a4756066b9b2426e5b707 100644 (file)
--- a/README
+++ b/README
@@ -3,7 +3,7 @@ net releases.
 
 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"
@@ -14,15 +14,15 @@ TODO:
   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.
@@ -59,3 +59,5 @@ recently completed
    * 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.
index da4cdb4dcd5b815b353e8191d01564bb28c4e7e8..aec9b8fd4c76031a7a967bd65235d3ef8a5d740b 100644 (file)
@@ -22,7 +22,7 @@
 
 /* normal members */
 
-Category::Category ():next (0), name (0), packages (0)
+Category::Category ():next (0), name (0), key (0), packages (0)
 {
 }
 
@@ -32,4 +32,11 @@ 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);
 }
index d1e774edd6ca949cb699fe413aded1544e7a4dca..542dc2c42a1f363d60779d6d47e1df3f8c5fabe0 100644 (file)
@@ -28,8 +28,10 @@ public:
 
   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_ */
diff --git a/category_list.cc b/category_list.cc
deleted file mode 100755 (executable)
index 2918af3..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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;
-}
diff --git a/category_list.h b/category_list.h
deleted file mode 100755 (executable)
index f51c5f4..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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_ */
index e7efad41921658341485994874aefef1feb101ed..0ac1779f7e3b6721de8996e3f2650045e613d181 100644 (file)
--- a/choose.cc
+++ b/choose.cc
@@ -48,7 +48,6 @@ static const char *cvsid =
 #include "io_stream.h"
 #include "choose.h"
 #include "category.h"
-#include "category_list.h"
 
 #include "package_db.h"
 #include "package_meta.h"
@@ -97,7 +96,7 @@ static struct _header cat_headers[] = {
   {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)
@@ -176,9 +175,9 @@ set_action (packagemeta * pkg)
     }
   /* 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;
@@ -243,7 +242,7 @@ add_required (packagemeta & pkg, size_t depth = 0)
   dp = pkg.desired->required;
   packagedb db;
   /* cheap test for too much recursion */
-  if (depth > db.npackages ())
+  if (depth > 5)
     return 0;
   while (dp)
     {
@@ -539,8 +538,8 @@ fill_missing_category ()
   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
@@ -551,8 +550,9 @@ default_trust (HWND h, trusts trust)
   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)
@@ -628,10 +628,10 @@ pick_line::paint (HDC hdc, int x, int y, int row, int show_cat)
              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;
@@ -775,9 +775,8 @@ _view::init_headers (HDC dc)
        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
@@ -811,7 +810,7 @@ _view::insert_pkg (packagemeta & pkg)
        {
          lines =
            (pick_line *) calloc (db.npackages () +
-                                 db.categories.categories (),
+                                 db.categories.number (),
                                  sizeof (pick_line));
          nlines = 0;
          insert_at (0, line);
@@ -822,9 +821,9 @@ _view::insert_pkg (packagemeta & pkg)
   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;
@@ -832,7 +831,7 @@ _view::insert_pkg (packagemeta & pkg)
            {
              /* 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;
@@ -842,7 +841,7 @@ _view::insert_pkg (packagemeta & pkg)
          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);
            }
        }
@@ -858,17 +857,17 @@ _view::insert_category (Category * cat, int collapsed)
     {
       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
     {
@@ -883,7 +882,7 @@ _view::insert_category (Category * cat, int collapsed)
              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)
@@ -898,7 +897,7 @@ _view::insert_category (Category * cat, int collapsed)
          if (!collapsed)
            for (CategoryPackage * catpkg = cat->packages; catpkg;
                 catpkg = catpkg->next)
-             insert_pkg (catpkg->pkg);
+             insert_pkg (*catpkg->pkg);
        }
     }
 }
@@ -1013,7 +1012,7 @@ _view::click (int row, int x)
               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);
@@ -1074,8 +1073,9 @@ set_view_mode (HWND h, views mode)
     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:
@@ -1085,9 +1085,9 @@ set_view_mode (HWND h, views mode)
       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;
@@ -1519,27 +1519,23 @@ do_choose (HINSTANCE h)
           " 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);
            }
index 5e30689442939e6abb6fba3cb75464af06628557..f1445319d0a9d21933cb75f66ab701255b091a05 100644 (file)
@@ -20,8 +20,6 @@
 #ifndef _CYGPACKAGE_H_
 #define _CYGPACKAGE_H_
 
-#include "category_list.h"
-
 class cygpackage:public packageversion
 {
 public:
index 0144996f0be0d9d3e7e8406cc802736d149c6b59..2e985ce91858139426f51fabd28b5d9485d4cfda 100644 (file)
--- a/geturl.cc
+++ b/geturl.cc
@@ -215,24 +215,24 @@ get_url_to_string (char *_url)
   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;
     }
@@ -247,10 +247,10 @@ get_url_to_string (char *_url)
       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)
index e9f1b216f687677e729b49cbc4e1b36393146501..b2a7be34bea258425cc157d0b619ae5ac867c621 100644 (file)
@@ -23,7 +23,6 @@
 #include "win32.h"
 #include "package_db.h"
 #include "category.h"
-#include "category_list.h"
 #include "ini.h"
 #include "iniparse.h"
 #include "filemanip.h"
@@ -139,9 +138,9 @@ requires
  ;
 
 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)); }
  ;
 
 %%
index 0c609234ebed4a01fe9856bece778182fe0b564d..8645ae3c3858dcb6878b1e66a3994865e9841915 100644 (file)
@@ -245,15 +245,11 @@ packagemeta & packagedb::registerpackage (char const *pkgname)
 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;
index 08a183b2ec936f3f0f3ebcaa2f3ffbe57e9369d1..64300270f13da493f2dba3d5882381e3316909b0 100644 (file)
 #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;
 
@@ -39,7 +42,7 @@ public:
     return packagecount;
   };
   /* all seen categories */
-  static CategoryList categories;
+  static list < Category, char const *, strcasecmp > categories;
 private:
   /* this gets sorted */
   static packagemeta **packages;
index cb9477b18a00ee9e678c0e95b8a2f1273f4bd5f8..37d3f2dd2b7539ff188a0b4ae423e81f0d71eae0 100644 (file)
@@ -144,13 +144,8 @@ void
 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 *
index 8af4390cb09beb9f487f0d30ab5037a45a26feb6..68c6e31d6f677fe112b55c1b900ad7c9954e2922 100644 (file)
 
 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;
 };
 
 
@@ -85,13 +89,8 @@ public:
   /* 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. */
@@ -109,8 +108,6 @@ public:
   /* Now for the user stuff :] */
   /* What version does the user want ? */
   packageversion *desired;
-private:
-  CategoryList categories;
 };
 
 #endif /* _PACKAGE_META_H_ */
This page took 0.064528 seconds and 5 git commands to generate.