Chinaunix首页 | 论坛 | 博客

分类: LINUX

2011-10-03 10:52:19

path_end(base);/* 1、___________-------->base 是url 地址,src/url.c*/
1714 static const char *
1715 path_end (const char *url)
1716 {
1717   enum url_scheme scheme = url_scheme (url); /*检查是哪种格式的传输协议2、______---------->/src/url.c*/
1718   const char *seps;
1719   if (scheme == SCHEME_INVALID)
1720     scheme = SCHEME_HTTP;       /* use http semantics for rel links */
1721   /* +2 to ignore the first two separators ':' and '/' */
1722   seps = init_seps (scheme) + 2;  /*4、_____---------->src/url.c*/
1723   return strpbrk_or_eos (url, seps);  /*5、_____--------->/src/url.c*/
1724 }
2、____________---------->

426 url_scheme (const char *url)
427 {
428   int i;
429     
430   for (i = 0; supported_schemes[i].leading_string; i++)  /*supported_schemes[]中保存协议++++----------------->*/
431     if (0 == strncasecmp (url, supported_schemes[i].leading_string,
432                           strlen (supported_schemes[i].leading_string))) /*strncasecmp就是比较的*/
433       {
434         if (!(supported_schemes[i].flags & scm_disabled)) /*如果初始化成功。*/
435           return (enum url_scheme) i;   /*返回对应的协议格式*/
436         else
437           return SCHEME_INVALID;
438       }
439
440   return SCHEME_INVALID;
441 }
++++++++++------------>
60 struct scheme_data
  61 {
  62   /* Short name of the scheme, such as "http" or "ftp". */
  63   const char *name;
  64   /* Leading string that identifies the scheme, such as "https://". */
  65   const char *leading_string;
  66   /* 如果HTTPS端口没有被指定,那么就是那个80. */
  67   int default_port;   
  68   /* Various flags. */
  69   int flags;
  70 };
  53 enum {
  54   scm_disabled = 1,             /* for https when OpenSSL fails to init. */
  55   scm_has_params = 2,           /* whether scheme has ;params */
  56   scm_has_query = 4,            /* whether scheme has ?query */
  57   scm_has_fragment = 8          /* whether scheme has #fragment */
  58 };


73 static struct scheme_data supported_schemes[] =
  74 {
  75   { "http",     "http://",  DEFAULT_HTTP_PORT,  scm_has_query|scm_has_fragment },
  76 #ifdef HAVE_SSL
  77   { "https",    "https://", DEFAULT_HTTPS_PORT, scm_has_query|scm_has_fragment },
  78 #endif
  79   { "ftp",      "ftp://",   DEFAULT_FTP_PORT,   scm_has_params|scm_has_fragment },
  80
  81   /* SCHEME_INVALID */
  82   { NULL,       NULL,       -1,                 0 }
  83 };
  84

如果你看到这里的话应该就明白了*/
4、____--------------->
620 static const char *
621 init_seps (enum url_scheme scheme)
622 {
623   static char seps[8] = ":/";
624   char *p = seps + 2;
625   int flags = supported_schemes[scheme].flags;
626
627   if (flags & scm_has_params)
628     *p++ = ';';
629   if (flags & scm_has_query)
630     *p++ = '?';
631   if (flags & scm_has_fragment)
632     *p++ = '#';
633   *p = '\0';            /*根据上述的flags代表的属性来赋值*/
634   return seps;
635 }
5、________________------------>
596 strpbrk_or_eos (const char *s, const char *accept)
597 {
598   char *p = strpbrk (s, accept);  /*函数的用途:在源字符串(source-string)中找出最先含有搜索字符串(searching-string)中的任一字符的位置并返回,若找不到则返回空指针。 */
599   if (!p)
600     p = strchr (s, '\0');
601   return p;
602 }
<------------------________________
返回到is_robot_txt_url()
{
. . . .
xfree(robots_url); /*释放的分配的那部分空间*/

<------------------_____________

到 test_is_robots_txt_url()]

  assert()
}
分析此函数完毕*/
阅读(711) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~