93d7e16befec162aaa7fefbce24137788b407b87
kate
  Mon May 11 12:10:34 2015 -0700
Cleanup hub check code and add new data structs to prep for hub versioning. refs #10015

diff --git src/hg/inc/trackHub.h src/hg/inc/trackHub.h
index 63c01ba..6467f19 100644
--- src/hg/inc/trackHub.h
+++ src/hg/inc/trackHub.h
@@ -32,49 +32,74 @@
     char *url;		/* URL of hub.ra file. */
     struct trackHubGenome *genomeList;	/* List of associated genomes. */
     struct hash *genomeHash;	/* Hash of genomeList keyed by genome name. */
     struct hash *settings;	/* Settings from hub.ra file. */
 
     /* Required settings picked out for convenience. All allocated in settings hash */
     char *shortLabel;	/* Hub short label. Not allocated here. */
     char *longLabel;	/* Hub long label. Not allocated here. */
     char *genomesFile;	/* URL to genome.ra file. Not allocated here. */
     char *defaultDb;    /* the default database  */
 
     char *name;	/* Symbolic name of hub in cart, etc.  From trackHubOpen hubName parameter. */
 
     char *descriptionUrl;  /* URL to description file */
     char *email;           /* email address of contact person */
+    char *version;  /* version compliance of hub ("V1.0", etc.) */
+    char *level;    /* support level of hub ("core", "full") */
     };
 
 struct trackHubGenome
 /* A genome serviced within a track hub. */
     {
     struct trackHubGenome *next;
     char *name;	/* Something like hg18 or mm9, a UCSC assembly database name. */
     char *trackDbFile;	/* The base trackDb.ra file. */
     struct hash *settingsHash;	/* Settings from hub.ra file. */
     char *twoBitPath;  /* URL to twoBit.  If not null, this is an assmebly hub*/
     struct twoBitFile *tbf;  /* open handle to two bit file */
     char *groups;	     /* URL to group.txt file */
     char *defaultPos;        /* default position */
     char *organism;          /* organism name, like Human */
     char *description;       /* description, also called freeze name */
     struct trackHub *trackHub; /* associated track hub */
     unsigned orderKey;   /* the orderKey for changing the order from the order in the file */
     };
 
+struct trackHubCheckOptions
+/* How to check track hub */
+    {
+    char *version;              /* hub spec version to check */
+    boolean strict;             /* check hub is valid to 'core' level for version */
+    struct hash *extra;         /* additional trackDb settings to accept */
+    boolean checkFiles;         /* check remote files exist and are correct type */
+    };
+
+struct trackHubSetting
+/* Setting name and support level, from trackDbHub.html (the spec) */
+    {
+    struct trackHubSetting *next;
+    char *name;                 /* setting name */
+    char *level;                /* support level (core, full, new, deprecated) */
+    };
+
+struct trackHubSetting *trackHubSettingsForVersion(char *version, char *specUrl);
+/* Return list of settings with support level */
+
+char *trackHubVersionDefault();
+/* Return current hub version */
+
 void trackHubClose(struct trackHub **pHub);
 /* Close up and free resources from hub. */
 
 struct trackHub *trackHubOpen(char *url, char *hubName);
 /* Open up a track hub from url.  Reads and parses hub.ra and the genomesFile. 
  * The hubName is generally just the asciified ID number. */
 
 struct trackHubGenome *trackHubFindGenome(struct trackHub *hub, char *genomeName);
 /* Return trackHubGenome of given name associated with hub.  Return NULL if no
  * such genome. */
 
 struct trackDb *trackHubTracksForGenome(struct trackHub *hub, struct trackHubGenome *genome);
 /* Get list of tracks associated with genome.  Check that it only is composed of legal
  * types.  Do a few other quick checks to catch errors early. */
 
@@ -91,32 +116,31 @@
 
 char *trackHubRequiredSetting(struct trackHub *hub, char *name);
 /* Return named setting.  Abort with error message if not found. */
 
 char *trackHubRelativeUrl(char *hubUrl, char *path);
 /* Return full path (in URL form if it's a remote hub) given
  * path possibly relative to hubUrl. Do a freeMem of result
  * when done. */
 
 void trackHubGenomeFree(struct trackHubGenome **pGenome);
 /* Free up genome info. */
 
 void trackHubGenomeFreeList(struct trackHub *hub);
 /* Free a list of dynamically allocated trackHubGenome's. */
 
-int trackHubCheck(char *hubUrl, struct dyString *errors, 
-    boolean checkTracks, FILE *searchFp);
+int trackHubCheck(char *hubUrl, struct trackHubCheckOptions *options, struct dyString *errors);
 /* trackHubCheck - Check a track data hub for integrity. Put errors in dyString.
  *      if checkTracks is TRUE, individual tracks are checked
  *      if searchFp is non-null, then put search terms in there
  *      return 0 if hub has no errors, 1 otherwise */
 
 void trackHubPolishTrackNames(struct trackHub *hub, struct trackDb *tdbList);
 /* Remove all the special characters from trackHub track names. */
 
 char *trackHubCladeToGenome(char *clade);
 /* Given a track hub clade(hub name) return the default genome. */
 
 boolean trackHubDatabase(char *database);
 /* Is this an assembly from an Assembly Data hub? */
 
 char *trackHubDefaultChrom(char *database);