<-------------______________
返回到all_tests()
{
. . . . . /*The last one is coming*/
mu_run_test(test_is_robots_txt_url); /*和那spider有关1、_____________------------->src/res.c*/
. . . . . .
}
1、____________-------------->
618 test_is_robots_txt_url()
619 {
620 int i;
621 struct {
622 char *url;
623 bool expected_result;
624 } test_array[] = {
625 { "", true }, /*因为此文件在服务器根目录所以只有它是正确的*/
626 { "", false },
627 { "robots.txt", false },
628 };
629
630 for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i)
631 {
632 mu_assert ("test_is_robots_txt_url: wrong result",
633 is_robots_txt_url (test_array[i].url) == test_array[i].expected_result);
/*2、_________------------>/src/res.c*/
634 }
635
636 return NULL;
637 }
2、_____________--------------->
586 bool
587 is_robots_txt_url (const char *url)
588 {
589 char *robots_url = uri_merge (url, RES_SPECS_LOCATION); /*3、________------------>/src/url.c*/
590 bool ret = are_urls_equal (url, robots_url);
591
592 xfree (robots_url);
593
594 return ret;
595 }
3、____________----------------->
#define RES_SPECS_LOCATION "/robots.txt"
1743 uri_merge (const char *base, const char *link)
1744 {
1745 int linklength;
1746 const char *end;
1747 char *merge;
1748
1749 if (url_has_scheme (link))4、_________---------->src/url.c*/
1750 return xstrdup (link); 5、__________----------->/xmalloc.c*/
1751
1752 /* We may not examine BASE past END. */
1753 end = path_end (base);
1754 linklength = strlen (link);
1755
1756 if (!*link)
1757 {
1758 /* Empty LINK points back to BASE, query string and all. */
1759 return xstrdup (base);
1760 }
1761 else if (*link == '?')
1762 {
1763 /* LINK points to the same location, but changes the query
1764 string. Examples: */
1765 /* uri_merge("path", "?new") -> "path?new" */
1766 /* uri_merge("path?foo", "?new") -> "path?new" */
1767 /* uri_merge("path?foo#bar", "?new") -> "path?new" */
1768 /* uri_merge("path#foo", "?new") -> "path?new" */
1769 int baselength = end - base;
1770 merge = xmalloc (baselength + linklength + 1);
1771 memcpy (merge, base, baselength);
1772 memcpy (merge + baselength, link, linklength);
1773 merge[baselength + linklength] = '\0';
1774 }
1775 else if (*link == '#')
. . .
4、_____________________------------->
url_has_scheme (const char *url) 意思是如果以scheme格式,开始的话就返回1,如果不要就返回0.
/*这个函数解释了url格式中的skeme,我查资料没有查到*/
5、__________________-------------------->
120 char *
121 xstrdup (char const *string)
122 {
123 return xmemdup (string, strlen (string) + 1);
124 }
113 xmemdup (void const *p, size_t s)
114 {
115 return memcpy (xmalloc (s), p, s);
116 }
/*这是复制一份该字符串的值*/
阅读(563) | 评论(0) | 转发(0) |