Chinaunix首页 | 论坛 | 博客

分类: LINUX

2011-10-12 14:12:38

网络sock初始化
  1. 1213   sock_init();
复制代码
  1. 获得url地址
  2. 1225   url = alloca_array (char *, nurl + 1); /urll长度定义为 1070   nurl = argc - optind; /*前面选项后面的字串长度*/
  3. 1226   for (i = 0; i < nurl; i++, optind++)  /*
  4. 1227     {
  5. 1228       char *rewritten = rewrite_shorthand_url (argv[optind]); 1、_____-------->从新写url地址,也有检查的意思*/
  6. 1229       if (rewritten)
  7. 1230         url[i] = rewritten;
  8. 1231       else
  9. 1232         url[i] = xstrdup (argv[optind]);
  10. 1233     }
  11. 1、_____________----------->
  12. 547 char *
  13. 548 rewrite_shorthand_url (const char *url)
  14. 549 {
  15. 550   const char *p;
  16. 551   char *ret;
  17. 552      
  18. 553   if (url_scheme (url) != SCHEME_INVALID) /*url_scheme()检查是否为支持的格式2、______--->*/
  19. 554     return NULL;
复制代码
  1. url_skeme()函数就是比较使用,比较简单,不说了*/
  2. 425 enum url_scheme
  3. 426 url_scheme (const char *url)
  4. 427 {
  5. 428   int i;
  6. 429
  7. 430   for (i = 0; supported_schemes[i].leading_string; i++)
  8. 431     if (0 == strncasecmp (url, supported_schemes[i].leading_string,
  9. 432                           strlen (supported_schemes[i].leading_string)))
  10. 433       {
  11. 434         if (!(supported_schemes[i].flags & scm_disabled))
  12. 435           return (enum url_scheme) i;
  13. 436         else
  14. 437           return SCHEME_INVALID;
  15. 438       }
  16. 439
  17. 440   return SCHEME_INVALID;
  18. 441 }
复制代码
  1. 73 static struct scheme_data supported_schemes[] =
  2.   74 {
  3.   75   { "http",     "http://",  DEFAULT_HTTP_PORT,  scm_has_query|scm_has_fragm     ent },
  4.   76 #ifdef HAVE_SSL
  5.   77   { "https",    "https://", DEFAULT_HTTPS_PORT, scm_has_query|scm_has_fragm     ent },
  6.   78 #endif
  7.   79   { "ftp",      "ftp://",   DEFAULT_FTP_PORT,   scm_has_params|scm_has_frag     ment },
  8.   80
  9.   81   /* SCHEME_INVALID */
  10.   82   { NULL,       NULL,       -1,                 0 }
  11.   83 };
复制代码
阅读(918) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~