-static int download( const char *hostname, const char *uri, const char *fn, int sendhostname)
+static int check_map_file(FILE* f)
+{
+ char **s;
+ char *bp;
+ int res = 0; /* good */
+ fpos_t pos;
+ char buf[33];
+ size_t nr;
+ char * html_str[] = {
+ "<html",
+ "<!DOCTYPE html",
+ "<head",
+ "<title",
+ NULL
+ };
+
+
+ bzero(buf, sizeof(buf));
+ fgetpos(f, &pos);
+ rewind(f);
+ nr = fread(buf, 1, sizeof(buf) - 1, f);
+ fsetpos(f, &pos);
+ for (bp = buf; (bp < (buf + sizeof(buf) - 1)) && (nr > (bp - buf)); bp++) {
+ if (!(isspace(*bp)))
+ break;
+ }
+ if ((bp >= (buf + sizeof(buf) -1)) || ((bp - buf) >= nr))
+ return(res);
+ for (s = html_str; *s; s++) {
+ if (strncmp(*s, bp, strlen(*s)) == 0)
+ return(-1);
+ }
+ return(res);
+}
+
+static int download( const char *hostname, const char *uri, const char *fn, DownloadOptions *options)