Question on new structures in setup [C++ Question]

Brian Keener bkeener@thesoftwaresource.com
Tue Jul 17 07:42:00 GMT 2001


Okay,

Pardon my taking this mailing list into C++ programming questions but:

I decided to try to help again - seems things may have quieted a little on 
setup.exe and I was trying to understand on the new code, learn a little and 
try to work a little on cleaning up the actions for the packages.  I have been 
trying to understand the new package structure that Chris redesigned when he 
cleaned up the multiple structures and did some combining.  

Looking at ini.h I see the structure definition for Info:

typedef struct _Info
{
  char *version;        /* version part of filename */
  char *install;        /* file name to install */
  int install_size;     /* in bytes */
  int install_exists;   /* install file exists on disk */
  int derived;          /* True if we "figured out" that this version should
                           go here but it was not in setup.ini */
  char *source;         /* sources for installed binaries */
  int source_size;      /* in bytes */
  int source_exists;    /* source file exists on disk */
#ifdef __cplusplus
  _Info (const char *_install, const char *_version,
         int _install_size, const char *_source = NULL,
         int _source_size = 0);
#endif
} Info;                 /* +1 for TRUST_UNKNOWN */

and then I see the structure definition for Package:

typedef struct
{
  char *name;           /* package name, like "cygwin" */
  char *sdesc;          /* short description (replaces "name" if provided) */
  char *ldesc;          /* long description (multi-line) */
  Dependency *required; /* the packages required for this package to work */
  Category *category;   /* the categories the package belongs to */ 
  actions action;       /* A range of states applicable to this package */
  trusts trust;         /* Selects among info[] below, a subset of action */
  int srcpicked;        /* True if source is required */

  Info *installed;      /* Info on installed package */
  trusts installed_ix;  /* Index into info array for currently installed 
package
 */
  excludes exclude;     /* true if this package should be excluded */

  /* The reason for this weird layout is to allow for loops that scan either
     the info array, based on trust value or the infoscan array based on a 
point
er,
     looking for a particular version. */
  Info info[1];                 /* First element.  Intentionally allocated 
prior
                                   to infoscan */
  Info infoscan[NTRUST - 1];    /* +1 for TRUST_UNKNOWN */
  Info infoend[0];              /* end marker */
} Package;

Now Info I remember as it is a lot like part of what was originally used and 
Package looks similar as well .... But I am not sure I understand the installed 
and the Info in the package structure.   If I read it correctly the Info 
info[1] definition in package is setting up an array (for lack of a better 
term) where I can store filenames, actions, existence and such for many 
different versions of this package(each as it owns record within package - sort 
of).  The Installed appears to be another instance of the Info structure which 
is used to store the current installed version separate from the available 
version in info[].  But looking at the source it doesn't appear that all the 
fields in the installed structure get populated.  

In read_installed_db in choose.cc I see where we populate the info structure 
with info we read from the installed.db file and I see this line:

 pkg->installed = new Info (inst, f.ver, instsz);
 
Which appears to be creating the installed structure in Package.  As you can 
see we never assign the install_exists and some other fields and this 
definition does not seem to match the Info structure either.  

The reason for my questions is I am trying to determine if when the current 
installed version is prior to even the previous version in the setup.ini is 
this information kept in the Package structure.  My thought is that yes it is 
kept in pkg->installed->install, pkg->installed->version and such and that we 
should also be using pkg->installed->install_exists (or at least I need it for 
what I am working on).  Then the info[] still tracks the prev, current, and 
test from setup.ini.

How am I doing so far.  Is the above correct and is pkg->Installed a single 
entity structure of Info and pkg->info[???] is a multiple entity structure of 
Info.

Thanks for any clarification.

bk




More information about the Cygwin-developers mailing list