9bc582ab8e1aa2bd06d2ea0a87e3970b427f795b
galt
  Tue Apr 16 13:18:14 2019 -0700
fixing it to support standard dependencies in the head tag, then portal top menu, then cdwSubmit menu, then page footer automatically so that the code does not have to be written and maintained at great effort. refs#22283

diff --git src/hg/cirm/cdw/cdwGetFile/cdwGetFile.c src/hg/cirm/cdw/cdwGetFile/cdwGetFile.c
index dcdb166..72ef033 100644
--- src/hg/cirm/cdw/cdwGetFile/cdwGetFile.c
+++ src/hg/cirm/cdw/cdwGetFile/cdwGetFile.c
@@ -42,51 +42,89 @@
 void mustHaveAccess(struct sqlConnection *conn, struct cdwFile *ef)
 /* exit with error message if user does not have access to file ef */
 {
 boolean isPublic = cfgOptionBooleanDefault("cdw.siteIsPublic", FALSE);
 if (isPublic)
     return;
 if (cdwCheckAccess(conn, ef, user, cdwAccessRead))
     return;
 else
     if (user==NULL)
         errExit("Sorry, this file has access restrictions. Please <a href='/cgi-bin/hgLogin'>log in</a> first.", NULL);
     else
         errExit("Sorry, user %s does not have access to this file.", user->email);
 }
 
+struct patcher 
+/* deal with patching replacement bits in html */
+    {
+    struct patcher *next;
+    char *match; // string to match
+    int size;   // string size
+    int count;   // match count
+    char *(*cdwLocalFunction)(struct cart *cart, boolean makeAbsolute);  // function to make
+    };
+
 static void printFileReplaceVar(char *filePath) 
 /* dump a text file to stdout with the html header, replace <!--menuBar--> with the menubar */
 {
 printf("Content-Type: text/html\n\n");
 
 int c;
 FILE *file = fopen(filePath, "r");
 if (file == 0) 
     errExit("Cannot open file %s", filePath);
 
-char searchStr[] = "<!--menuBar-->";
-int matchCount = 0;
+struct patcher *patcherList = NULL, *p = NULL;
+
+AllocVar(p);
+p->match = cloneString("<!--headDependencies-->");
+p->cdwLocalFunction = &cdwHeadTagDependencies;
+slAddHead(&patcherList, p);
+AllocVar(p);
+p->match = cloneString("<!--pageHeader-->");
+p->cdwLocalFunction = &cdwPageHeader;
+slAddHead(&patcherList, p);
+AllocVar(p);
+p->match = cloneString("<!--menuBar-->");
+p->cdwLocalFunction = &cdwLocalMenuBar;
+slAddHead(&patcherList, p);
+AllocVar(p);
+p->match = cloneString("<!--pageFooter-->");
+p->cdwLocalFunction = &cdwPageFooter;
+slAddHead(&patcherList, p);
+
+for(p=patcherList; p; p=p->next)
+    {
+    p->size = strlen(p->match);
+    }
 while ((c = getc(file)) != EOF)
     {
-    if (c==searchStr[matchCount])
-        matchCount++;
-    else
-        matchCount = 0;
     putchar(c);
-    if (matchCount==sizeof(searchStr)-1)
-        puts(cdwLocalMenuBar(cart, TRUE));
+
+    for(p=patcherList; p; p=p->next)
+	{
+	if (c==p->match[p->count])
+	    p->count++;
+	else
+	    p->count = 0;
+	if (p->count==p->size)
+	    {
+	    puts((*p->cdwLocalFunction)(cart, TRUE));
+	    }
+	}
+
     }
 fclose(file);
 }
 
 void sendFile(char *format, char *filePath, char *suggestFileName)
 /* format is one of "fastq", "fasta", defined in cdw.as. if format is NULL, use file extension. */
 /* send file to user via Apache, using X-Sendfile or stdout, as needed */
 {
 if (format==NULL || sameWord(format, "unknown"))
 {
     char ext[FILEEXT_LEN];
     splitPath(filePath, NULL, NULL, ext);
     if (strlen(ext)>1)
         {
         format = cloneString(ext);