1f1ad77303a89026caa686b37d4199a62c94bf43
kent
  Tue Feb 1 12:38:07 2011 -0800
Making it so that track html description is fetched for hgc and hgTrackUi.  To do this had to get a way to fetch a text file from a URL without putting up any warning messages if it was not there, which ended up requiring a new warning handler.
diff --git src/lib/net.c src/lib/net.c
index 91989c7..30eef80 100644
--- src/lib/net.c
+++ src/lib/net.c
@@ -1213,32 +1213,32 @@
 	    }
 	}
     if (!success)
 	{  /* failure after 0 to 5 redirects */
 	if (redirectCount > 0)
 	    freeMem(newUrl);
 	return FALSE;
 	}
     url = newUrl;
     }
 return FALSE;
 }
 
 struct lineFile *netLineFileMayOpen(char *url)
 /* Return a lineFile attached to url. http skips header.
- * Supports some compression formats.
- * Return NULL if there's a problem. */
+ * Supports some compression formats.  Prints warning message, but
+ * does not abort, just returning NULL if there's a problem. */
 {
 int sd = netUrlOpen(url);
 if (sd < 0)
     {
     warn("Couldn't open %s", url);
     return NULL;
     }
 else
     {
     struct lineFile *lf = NULL;
     char *newUrl = NULL;
     int newSd = 0;
     if (startsWith("http://",url) || startsWith("https://",url))
 	{  
 	if (!netSkipHttpHeaderLinesHandlingRedirect(sd, url, &newSd, &newUrl))
@@ -1257,30 +1257,53 @@
     	endsWith(url, ".bz2"))
 	{
 	lf = lineFileDecompressFd(url, TRUE, sd);
            /* url needed only for compress type determination */
 	}
     else
 	{
 	lf = lineFileAttach(url, TRUE, sd);
 	}
     if (newUrl) 
 	freeMem(newUrl); 
     return lf;
     }
 }
 
+struct lineFile *netLineFileSilentOpen(char *url)
+/* Open a lineFile on a URL.  Just return NULL without any user
+ * visible warning message if there's a problem. */
+{
+pushSilentWarnHandler();
+struct lineFile *lf = netLineFileMayOpen(url);
+popWarnHandler();
+return lf;
+}
+
+char *netReadTextFileIfExists(char *url)
+/* Read entire URL and return it as a string.  URL should be text (embedded zeros will be
+ * interpreted as end of string).  If the url doesn't exist or has other problems,
+ * returns NULL. */
+{
+struct lineFile *lf = netLineFileSilentOpen(url);
+if (lf == NULL)
+    return NULL;
+char *text = lineFileReadAll(lf);
+lineFileClose(&lf);
+return text;
+}
+
 
 struct parallelConn
 /* struct to information on a parallel connection */
     {
     struct parallelConn *next;  /* next connection */
     int sd;                     /* socket descriptor */
     off_t rangeStart;           /* where does the range start */
     off_t partSize;             /* range size */
     off_t received;             /* bytes received */
     };
 
 void writeParaFetchStatus(char *origPath, struct parallelConn *pcList, char *url, off_t fileSize, char *dateString, boolean isFinal)
 /* Write a status file.
  * This has two purposes.
  * First, we can use it to resume a failed transfer.