8 #include "fastestmirror.h"
13 findmetalinkurl(FILE *fp, unsigned char *chksump, Id *chksumtypep)
15 char buf[4096], *bp, *ep;
22 while((bp = fgets(buf, sizeof(buf), fp)) != 0)
24 while (*bp == ' ' || *bp == '\t')
26 if (chksumtypep && !*chksumtypep && !strncmp(bp, "<hash type=\"sha256\">", 20))
29 if (solv_hex2bin((const char **)&bp, chksump, 32) == 32)
30 *chksumtypep = REPOKEY_TYPE_SHA256;
33 if (strncmp(bp, "<url", 4))
39 ep = strstr(bp, "repodata/repomd.xml</url>");
43 if (strncmp(bp, "http", 4))
45 urls = solv_extend(urls, nurls, 1, sizeof(*urls), 15);
46 urls[nurls++] = strdup(bp);
51 findfastest(urls, nurls > 5 ? 5 : nurls);
54 for (i = 0; i < nurls; i++)
58 if ((ep = strchr(ep + 2, '/')) != 0)
61 printf("[using mirror %s]\n", bp);
70 findmirrorlisturl(FILE *fp)
72 char buf[4096], *bp, *ep;
77 while((bp = fgets(buf, sizeof(buf), fp)) != 0)
79 while (*bp == ' ' || *bp == '\t')
81 if (!*bp || *bp == '#')
84 while (l > 0 && (bp[l - 1] == ' ' || bp[l - 1] == '\t' || bp[l - 1] == '\n'))
86 if ((ep = strstr(bp, "url=")) != 0)
88 urls = solv_extend(urls, nurls, 1, sizeof(*urls), 15);
89 urls[nurls++] = strdup(bp);
94 findfastest(urls, nurls > 5 ? 5 : nurls);
97 for (i = 0; i < nurls; i++)
100 ep = strchr(bp, '/');
101 if ((ep = strchr(ep + 2, '/')) != 0)
104 printf("[using mirror %s]\n", bp);