Larbin 搜索引擎源码赏析——(二)搜索引擎的全局变量类

  1. // Larbin
  2. // Sebastien Ailleret
  3. // 29-11-99 -> 08-03-00
  4. #include <unistd.h>
  5. #include <sys/socket.h>
  6. #include <netinet/in.h>
  7. #include <errno.h>
  8. #include <fcntl.h>
  9. #include <iostream.h>
  10. #include <string.h>
  11. #include <adns.h>
  12. #include <netdb.h>
  13. #include <sys/socket.h>
  14. #include "types.h"
  15. #include "global.h"
  16. #include "xutils/text.h"
  17. #include "xutils/Fifo.h"
  18. #include "xutils/Site.h"
  19. #include "xutils/debug.h"
  20. #include "xutils/MaxedSizedFifo.h"
  21. #include "xutils/PersistentFifo.h"
  22. #include "xutils/ConstantSizedFifo.h"
  23. #include "xutils/ConstantSizedFifoPriority.h"
  24. ///
  25. // Struct global
  26. ///
  27. // define all the static variables
  28. //静态变量的定义过程,其中包括类中的静态成员变量。
  29. hashTable *global::seen;
  30. //变量的类型是模板类
  31. GenericFifo<url> *global::URLsInput;
  32. GenericFifo<url> *global::URLsInternal;
  33. Site *global::siteList;
  34. GenericFifo<Site> *global::okSites;
  35. GenericFifo<Site> *global::dnsSites;
  36. Connexion **global::connexions;
  37. adns_state global::ads;
  38. ConstantSizedFifoPriority<Connexion> *global::freeConns;
  39. ConstantSizedFifo<Connexion> *global::userConns;
  40. Interval *global::inter;
  41. uint global::depthInSite;
  42. time_t global::waitDuration;
  43. char *global::userAgent;
  44. char *global::sender;
  45. char *global::headers;
  46. sockaddr_in *global::proxyAddr;
  47. bool global::isSpecific;
  48. char *global::contentType;
  49. char *global::privilegedExt;
  50. Vector<char> *global::domains;
  51. Vector<char> global::forbExt;
  52. char *global::firstUrl;
  53. uint global::nb_conn;
  54. uint global::dnsConn;
  55. unsigned short int global::httpPort;
  56. unsigned short int global::inputPort;
  57. /** Constructor : initialize allmost everything
  58.  * Everything is read from the config file (larbin.conf by default)
  59.  */
  60. global::global (int argc, char *argv[]) 
  61. {
  62.   char *configFile = "larbin.conf";
  63.   bool reload = false;  //判断是重新启动的还是第一次启动
  64.   
  65.   // verification of arguments
  66.   int pos = 1;
  67.   while (pos < argc)  
  68.   {
  69.     //argc 大于1,说明有参数
  70.         if (!strcmp(argv[pos], "-c") && argc > pos+1) 
  71.         {
  72.         configFile = argv[pos+1];  //#通过参数设置配置文件的名字
  73.         pos += 2;
  74.         } 
  75.         else if (!strcmp(argv[pos], "-reload"))  //重新启动,从上一次爬行结束时的状态开始
  76.         {
  77.         reload = true//#设置reload的,具体作用还不清楚。
  78.         pos++;
  79.         } 
  80.         else 
  81.         {
  82.         break;
  83.         }
  84.   }
  85.   
  86.   //程序的参数有错误,提示使用方法
  87.   if (pos != argc) 
  88.   { //#显示使用方法。
  89.         cerr << "usage : " << argv[0];
  90.         cerr << " [-c configFile] [-reload]/n";
  91.         exit(1);
  92.   }
  93. //#初始话设置
  94.   // Standard values
  95.   waitDuration = 60;  //访问同一服务器,的时间间隔,不能小于30s
  96.   depthInSite = 5;      //访问网页的最大深度
  97.   userAgent = "larbin"//机器人的名称
  98.   sender = "larbin@somewhere.com";  //发送者信息,构造http数据包时用。 
  99.   firstUrl = "http://localhost/";   //首先访问的url
  100.   nb_conn = 20;  //最大并行数连接数
  101.   dnsConn = 3;              //dns最大并行连接数
  102.   httpPort = 8081;      // 用通过web看Larbin抓取的统计情况的接口
  103.   inputPort = 1976;   //向Larbin添加url等输入信息的telnet接口
  104.   proxyAddr = NULL;   //代理服务器地址
  105.   isSpecific = false;  //是否是特定搜索
  106.   domains = NULL;   //域名限制
  107.   // Read the configuration file
  108.   
  109.   crash("Read the configuration file");  //在debug.h文件中有宏定义#define crash(s) (cerr << s << "/n")
  110.   parseFile(configFile); //#解析配置文件
  111.   
  112.   // Initialize everything
  113.   crash("Create global values");
  114.   // Headers
  115.   String strtmp;
  116.   strtmp.addString("/r/nUser-Agent: ");
  117.   strtmp.addString(userAgent);
  118.   strtmp.addString(" ");
  119.   strtmp.addString(sender);
  120.   strtmp.addString("/r/nAccept: text/html/r/n/r/n");
  121.   headers = strtmp.giveString();  //在头文件中定义static char *headers;
  122.   // FIFOs
  123.   
  124.   //这里的构造函数需要进一步关注
  125.   URLsInternal = new PersistentFifo<url>(fifoFile, reload, this);
  126.   URLsInput = new Fifo<url>;
  127.   inter = new Interval(ramUrls);
  128.   siteList = new Site[siteListSize];
  129.   okSites = new Fifo<Site>;
  130.   dnsSites = new Fifo<Site>;
  131.   
  132.   seen = new hashTable(!reload);   //初始化hash表,定义在头文件中static hashTable *seen;
  133.   userConns = new ConstantSizedFifo<Connexion>(nb_conn);    //定义已经使用的连接的队列
  134.   freeConns = new ConstantSizedFifoPriority<Connexion>(nb_conn);    //定义free未使用连接的队列
  135.   connexions = new Connexion *[nb_conn]; //定义保存连接信息的结构体数组指针
  136.   
  137.   for (uint i=0; i<nb_conn; i++) //循环次数为最大连接数
  138.   {
  139.         connexions[i] = new Connexion;  //创建连接信息结构体
  140.         freeConns->put(connexions[i]);  //将新创建的连接信息结构体,放到free连接队列中
  141.   }
  142.   // init non blocking dns calls
  143.   crash("Start adns");  //初始化dns调用
  144.   adns_initflags flags = adns_initflags (adns_if_nosigpipe | adns_if_noerrprint);
  145.     // adns_initflags (adns_if_nosigpipe);
  146.   adns_init(&ads, flags, NULL);
  147. }
  148. /** Destructor : never used because the program should never end !
  149.  */
  150. global::~global () 
  151. {
  152.   cerr << "Why he hell do you want to delete global !/n";
  153. }
  154. /
  155. //
  156. //函数功能:解析配置文件
  157. //参数:       char *file  配置文件的名称
  158. //返回值:  void
  159. //注:在构造函数global中调用
  160. /
  161. /** parse configuration file */
  162. void global::parseFile (char *file) 
  163. {
  164.   int fds = open(file, O_RDONLY);
  165.   if (fds < 0) 
  166.   {
  167.         cerr << "cannot open config file/n";
  168.         exit(1);
  169.   }
  170.   char *tmp = readfile(fds); //在text.h文件中定义, 在函数中申请了与文件长度相等的buf
  171.   close(fds);  //关闭文件
  172.   
  173.   // suppress commentary
  174.   bool eff = false;
  175.   
  176.   //去掉配置文件中的用“#”标记的注释行,把“#”开头的行的数据全部变为空格符
  177.   for (int i=0; tmp[i] != 0; i++) 
  178.   {
  179.         switch (tmp[i]) 
  180.         {
  181.             case '/n'
  182.                 eff = false
  183.                 break;
  184.             case '#'
  185.                 eff = true// no break !!!
  186.             default
  187.                 if (eff) tmp[i] = ' ';
  188.         }
  189.   }
  190.   
  191.   String content;  //字符串类string.h文件中有定义
  192.   content.addString(tmp);
  193.   
  194.   delete [] tmp;
  195.   
  196.   uint pos = 0;
  197.   char *tok = nextToken(content, &pos);   //在text.h文件中定义,函数功能:从字符串中提取下一个单词,nextToken中
  198.                                                                                 //会重新申请一个空间来保存提取出来的单词,所以在使用完之后要注意释放这个空间
  199.   
  200.   while (tok != NULL) 
  201.   {
  202.             if (!strcasecmp(tok, "UserAgent")) 
  203.             {
  204.                     //读取配置文件中的用户代理信息
  205.                 delete [] tok;
  206.                 userAgent = nextToken(content, &pos);
  207.             } 
  208.             else if (!strcasecmp(tok, "From")) 
  209.             {
  210.                     //读取配置文件中的蜘蛛所有者的电子邮件信息
  211.                 delete [] tok;
  212.                 sender = nextToken(content, &pos);
  213.             } 
  214.             else if (!strcasecmp(tok, "startUrl")) 
  215.             {
  216.                     //读取配置文件中的,第一个爬取的url信息
  217.                 delete [] tok;
  218.                 firstUrl = nextToken(content, &pos);
  219.             } 
  220.             else if (!(tok, "waitduration")) 
  221.             {
  222.                     //读取配置文件中的,访问同一web服务器的间隔时间
  223.                 delete [] tok;
  224.                 tok = nextToken(content, &pos);
  225.                 waitDuration = atoi(tok); //将字符串转换为整形数字
  226.                 delete [] tok;
  227.             } 
  228.             else if (!strcasecmp(tok, "proxy")) 
  229.             {
  230.                     //读取配置文件中的代理服务器信息
  231.                 delete [] tok;
  232.                 // host name and dns call
  233.                 tok = nextToken(content, &pos);  //代理服务器的主机名  content为从配置文件中读取的字符串
  234.                 struct hostent* hp;
  235.                 proxyAddr = new sockaddr_in;
  236.                 bzero((char *)proxyAddr, sizeof (struct sockaddr_in)); //保存代理服务器信息的proxyAddr变量清0
  237.                 
  238.                 if ((hp = gethostbyname(tok)) == NULL)  //返回对应于给定主机名的主机信息。
  239.                 {
  240.                             endhostent(); //这个函数的作用还不清楚
  241.                             cerr << "Unable to find proxy ip address/n";
  242.                             exit(1); //退出啊
  243.                 } 
  244.                 else 
  245.                 {
  246.                             proxyAddr->sin_family = hp->h_addrtype;
  247.                             memcpy ((char*) &proxyAddr->sin_addr, hp->h_addr, hp->h_length);
  248.                 }//((hp = gethostbyname(tok)) == NULL)  
  249.       
  250.                 endhostent();
  251.                 delete [] tok;
  252.                 // port number
  253.                 tok = nextToken(content, &pos);  //获取端口信息
  254.                 proxyAddr->sin_port = htons(atoi(tok));
  255.                 delete [] tok;
  256.                 
  257.             } 
  258.             else if (!strcasecmp(tok, "pagesConnexions")) 
  259.             {
  260.                     //读取配置文件中的最大并行连接数的信息
  261.                 delete [] tok;
  262.                 tok = nextToken(content, &pos);
  263.                 nb_conn = atoi(tok);
  264.                 delete [] tok;
  265.             } 
  266.             else if (!strcasecmp(tok, "dnsConnexions")) 
  267.             {
  268.                     //读取配置文件中的DNS最大并行连接数的信息
  269.                 delete [] tok;
  270.                 tok = nextToken(content, &pos);
  271.                 dnsConn = atoi(tok);
  272.                 delete [] tok;
  273.             } 
  274.             else if (!strcasecmp(tok, "httpPort")) 
  275.             {
  276.                     //读取配置文件中留给使用者的查看抓取情况的web接口
  277.                 delete [] tok;
  278.                 tok = nextToken(content, &pos);
  279.                 httpPort = atoi(tok);
  280.                 delete [] tok;
  281.             } 
  282.             else if (!strcasecmp(tok, "inputPort")) 
  283.             {
  284.                   //读取配置文件中端口号,该端口号用于向Larbin添加url等输入信息的telnet接口
  285.                 delete [] tok;
  286.                 tok = nextToken(content, &pos);
  287.                 inputPort = atoi(tok);
  288.                 delete [] tok;
  289.             } 
  290.             else if (!strcasecmp(tok, "depthInSite")) 
  291.             {
  292.                     //读取配置文件中的,爬虫爬去的深度
  293.                 delete [] tok;
  294.                 tok = nextToken(content, &pos);
  295.                 depthInSite = atoi(tok);
  296.                 delete [] tok;
  297.             } 
  298.             else if (!strcasecmp(tok, "specificSearch")) 
  299.             {
  300.                     //读取配置文件中设置爬取某种格式文件的信息,如specificSearch audio/mpeg .mp3 end专门爬去mp3文件
  301.                 delete [] tok;
  302.                 if (isSpecific) 
  303.                 {
  304.                             cerr << "Bad configuration file : Two specificSearch fields/n";
  305.                             exit(1);
  306.                 }//end if
  307.                 
  308.                 isSpecific = true;
  309.                 contentType = nextToken(content, &pos);  //设置制定搜索的内容类型
  310.                 privilegedExt = nextToken(content, &pos);   //设置相对应的文件后缀名
  311.                 if (privilegedExt != NULL && !strcasecmp(privilegedExt, "end")) 
  312.                 {
  313.                         //当privilegedExt是结束符end是,将privilegedExt置空
  314.                             delete [] privilegedExt;
  315.                             privilegedExt = NULL;
  316.                 } 
  317.                 else 
  318.                 {
  319.                             tok = nextToken(content, &pos);
  320.                             if (tok == NULL || strcasecmp(tok, "end")) 
  321.                             {
  322.                                     //在读取一个字字符串,如果是NULL或不是end,则配置文件异常,推出
  323.                                 cerr << "Bad configuration file : no end to specificSearch/n";
  324.                                 exit(1);
  325.                             }//end (tok == NULL || strcasecmp(tok, "end"))
  326.                             delete [] tok;
  327.                 }//end if (privilegedExt != NULL && !strcasecmp(privilegedExt, "end"))
  328.                 
  329.             } 
  330.             else if (!strcasecmp(tok, "limitToDomain")) 
  331.             {
  332.                     //读取配置文件中,域名限制相关的信息
  333.                 delete [] tok;
  334.                 manageDomain(content, &pos);  //本类的成员变量
  335.             } 
  336.             else if (!strcasecmp(tok, "forbiddenExtensions")) 
  337.             {
  338.                     //读取配置文件中,禁止爬取的文件类型的信息
  339.                 delete [] tok;
  340.                 manageExt(content, &pos);  //本类的成员变量
  341.             } 
  342.             else 
  343.             {
  344.                 cerr << "bad configuration file : " << tok << "/n";
  345.                 exit(1);
  346.             }
  347.             
  348.             tok = nextToken(content, &pos);
  349.   }//end while
  350.   
  351. }//end function
  352. //
  353. //函数功能:设置域范围
  354. //参数:   String &content   所包含配置信息的字符串
  355. //              uint *pos                   当前需要处理的字符的位置
  356. //注:被parseFile函数调用
  357. //在parseFile函数中调用
  358. //
  359. /** read the domain limit */
  360. void global::manageDomain (String &content, uint *pos) 
  361. {
  362.   char *tok = nextToken(content, pos); //取一个子字符串
  363.   if (domains == NULL) 
  364.   {
  365.             domains = new Vector<char>;  //使用模板类创建字符串数组
  366.   }//end if
  367.   
  368.   while (tok != NULL && strcasecmp(tok, "end"))  //字符串不等于“end”,即没有结束
  369.   {
  370.             domains->addElement(tok); //这里的vector不是STL中的模板类,而是作者自己定义的模板,
  371.                                                                 //不妨学习一下数组模板的实现过程
  372.                                                                 //tok是一个字符创指针,将这个指针添加到domains的数组变量中,实际上domains相当于一个二维数字
  373.             tok = nextToken(content, pos);
  374.   }//end while
  375.   
  376.   if (tok == NULL) 
  377.   {
  378.             cerr << "Bad configuration file : no end to limitToDomain/n";
  379.             exit(1);
  380.   } 
  381.   else 
  382.   {
  383.             delete [] tok;
  384.   } //end if_else
  385. }
  386. /** read the forbidden extensions */
  387. /
  388. //
  389. //函数功能:设置禁止爬去的文件扩展名类型,实现方法与上个函数类似
  390. //参数:   String &content   所包含配置信息的字符串
  391. //              uint *pos                   当前需要处理的字符的位置
  392. //返回值:void
  393. //在parseFile函数中调用
  394. ///
  395. void global::manageExt (String &content, uint *pos) 
  396. {
  397.   char *tok = nextToken(content, pos);
  398.   
  399.   while (tok != NULL && strcasecmp(tok, "end")) 
  400.   {
  401.             forbExt.addElement(tok);
  402.             tok = nextToken(content, pos);
  403.   }//end while
  404.   
  405.   if (tok == NULL) 
  406.   {
  407.             cerr << "Bad configuration file : no end to forbiddenExtensions/n";
  408.             exit(1);
  409.   } 
  410.   else 
  411.   {
  412.             delete [] tok;
  413.   }//end if_else
  414.   
  415. }
  416. /** connect to this server using connection conn 
  417.  * return the state of the socket
  418.  */
  419.  
  420.  //
  421.  //函数功能:获得代理服务器的套接字 socket
  422.  //参数:Connexion *conn       保存连接信息的结构体
  423.  //返回值:char 返回连接的状态,EMPTY  CONNECTING WRITEOPEN几种
  424.  //
  425.  
  426. char global::getProxyFds (Connexion *conn) 
  427. {
  428.   assert (proxyAddr != NULL);
  429.   int fd = socket(AF_INET, SOCK_STREAM, 0); //创建套接字
  430.   if (fd < 0) 
  431.   {
  432.     //创建失败返回EMPTY
  433.     return EMPTY;
  434.   }
  435.   
  436.   conn->socket = fd;
  437.   for (;;) 
  438.   {
  439.         fcntl(fd, F_SETFL, O_NONBLOCK);  //函数的作用不清楚
  440.     if (connect(fd, (struct sockaddr*) proxyAddr,  //代理服务器的ip地址
  441.                 sizeof(struct sockaddr_in)) == 0) //连接代理地址
  442.     {
  443.       // success
  444.       //连接成功返回状态 WRITE
  445.       return WRITE; 
  446.     } 
  447.     else if (errno == EINPROGRESS)  //ein progress
  448.     {
  449.             // would block
  450.             //在非阻塞状态下会有这种情况
  451.             return CONNECTING; //connecting 
  452.     } 
  453.     else    
  454.     {
  455.                 // error
  456.                 (void) close(fd);
  457.                 return EMPTY;
  458.     }//end if_else
  459.     
  460.   }//end for
  461.   
  462. }//end function
  463. ///
  464. // Struct Connexion
  465. ///
  466. /** put Connection in a coherent state
  467.  */
  468. //
  469. //函数功能:构造函数
  470. //
  471. //
  472. ///
  473. Connexion::Connexion () 
  474. {
  475.   state = EMPTY;
  476.   parser = NULL;
  477. }
  478. /** Destructor : never used : we recycle !!!
  479.  */
  480. ///
  481. //
  482. //函数功能:析构函数
  483. //
  484. //
  485. ///
  486. Connexion::~Connexion () 
  487. {
  488.     
  489.   cerr << "My god, someone tries to delete a Connexion !/n";
  490.   
  491. }
  492. /** Recycle a connexion
  493.  */
  494. void Connexion::recycle () 
  495. {
  496.   delete parser;
  497.   request.recycle();
  498. }

 

 

        全局变量类的头文件:

        global.h文件

  1. // Larbin
  2. // Sebastien Ailleret
  3. // 18-11-99 -> 15-04-00
  4. /* This class contains all global variables */
  5. #ifndef GLOBAL_H
  6. #define GLOBAL_H
  7. #include <adns.h>
  8. #include <time.h>
  9. #include "xfetcher/file.h"
  10. #include "xfetcher/hashTable.h"
  11. #include "xutils/url.h"
  12. #include "xutils/Vector.h"
  13. #include "xutils/GenericFifo.h"
  14. #include "xutils/string.h"
  15. #include "xinterf/output.h"
  16. #include "xutils/ConstantSizedFifo.h"
  17. #include "xutils/ConstantSizedFifoPriority.h"
  18. // define for the state of a connection
  19. #define EMPTY 0
  20. #define CONNECTING 1
  21. #define WRITE 2
  22. #define OPEN 3
  23. class Site;
  24. class Interval;
  25. /** This represent a connection : we have a fixed number of them
  26.  * fetchOpen links them with servers
  27.  * fetchPipe reads those which are linked
  28.  */
  29. struct Connexion 
  30. {
  31.   char state;      // what about this socket : EMPTY, CONNECTING, WRITE, OPEN 连接状态
  32.   int pos;         // What part of the request has been sent  //作用还不太清楚
  33.                    // and how much have we received
  34.                    // pos is also used for reporting fetchError (awful hack)
  35.                    
  36.   int socket;      // number of the fds 套接字
  37.   time_t timeout;  // timeout for this connexion  //超时设置
  38.   String request;  // what is the http request 请求字符串
  39.   
  40.   file *parser;    // parser for the connexion (is it a robots.txt or an html file)
  41.                                  //文件指针
  42.   
  43.   /** Constructor */
  44.   Connexion ();
  45.   /** Dectructor : it is never used since we reuse connections */
  46.   ~Connexion ();
  47.   /** Recycle a connexion
  48.    */
  49.   void recycle (); //完成的工作,释放文件指针(delete),重新申请request字符串
  50. };
  51. class global 
  52. {
  53.   public:
  54.   /** Constructor : see global.cc for details */
  55.   global (int argc, char * argv[]);
  56.   /** Destructor : never used */
  57.   ~global ();
  58.   
  59.   /** List of pages allready seen (one bit per page) */
  60.   static hashTable *seen;
  61.   
  62.   /** URLs for the sequencer : each one has a different priority */
  63.   static GenericFifo<url> *URLsInput;  //保存url的一个队列
  64.   
  65.   /** This one has the lowest priority */
  66.   static GenericFifo<url> *URLsInternal;
  67.   
  68.   /** hashtable of the site we accessed (cache) */
  69.   static Site *siteList;
  70.   
  71.   /** Sites which have at least one url to fetch */
  72.   static GenericFifo<Site> *okSites;  //在变量在Site.cc 的void Site::putUrl (url *u) 函数中使用
  73.   
  74.   /** Sites which have at least one url to fetch
  75.    * but need a dns call
  76.    */
  77.   static GenericFifo<Site> *dnsSites;
  78.   
  79.   /** Informations for the fetch
  80.    * This array contain all the connections (empty or not)
  81.    */
  82.   static Connexion **connexions;
  83.   
  84.   /** Internal state of adns */
  85.   static adns_state ads;
  86.   
  87.   /** free connection for fetchOpen : connections with state==EMPTY */
  88.   static ConstantSizedFifoPriority<Connexion> *freeConns;
  89.   
  90.   /** free connection for fetchOpen : connections waiting for end user */
  91.   static ConstantSizedFifo<Connexion> *userConns;
  92.   
  93.   /** Sum of the sizes of a fifo in Sites */
  94.   static Interval *inter; //Interval类在Sit.h文件中有定义
  95.   
  96.   /** How deep should we go inside a site */
  97.   static uint depthInSite;  //访问网页的最大深度
  98.   
  99.   /** how many seconds should we wait beetween 2 calls at the same server 
  100.    * 0 if you are only on a personnal server, >=30 otherwise
  101.    */
  102.   static time_t waitDuration;  //访问相同的服务器的时间间隔
  103.   
  104.   /** Name of the bot */
  105.   static char *userAgent;  //机器人的名称
  106.   
  107.   /** Name of the man who lauch the bot */  //发起
  108.   static char *sender;  //发送者信息,构造http数据包时用。
  109.   
  110.   /** http headers to send with requests 
  111.    * sends name of the robots, from field...
  112.    */
  113.   static char *headers; //存放User-Agent.......等等一些列的字符串
  114.   
  115.   /* internet address of the proxy (if any) */
  116.   static sockaddr_in *proxyAddr;  //代理服务器地址信息
  117.   
  118.   
  119.   /** connect to this server through a proxy using connection conn 
  120.    * return >0 in case of success (connecting or connected), 0 otherwise
  121.    */
  122.   static char getProxyFds (Connexion *conn);
  123.   
  124.   /** Are we doing a specific search
  125.    */
  126.   static bool isSpecific; //是否做特定的搜索,文件后缀的限制,域名的限制
  127.   
  128.   /** What is the content-type we look for
  129.    */
  130.   static char *contentType;   //如果specificSearch audio/mpeg .mp3 end在配置文件中, contentType为audio/mpeg
  131.   
  132.   /** Is there a privileged extension //权限扩展
  133.    */
  134.   static char *privilegedExt;  //如果specificSearch audio/mpeg .mp3 end在配置文件中, privilegedExt为.mp3
  135.   
  136.   /** Limit to domain */
  137.   static Vector<char> *domains;  //域名限制
  138.   
  139.   /** forbidden extensions
  140.    * extensions which are allways to avoid : .ps, .pdf...
  141.    */
  142.   static Vector<char> forbExt;
  143.   
  144.   /** First URL to fetch : initiate the search */
  145.   static char *firstUrl;  //首先访问的url
  146.   
  147.   /** number of parallel connexions  并行
  148.    * your kernel must support a little more than nb_conn file descriptor
  149.    * select should be able to handle as many fds
  150.    */
  151.   static uint nb_conn;  //最大并行连接数
  152.   
  153.   /** number of parallel dns calls */
  154.   static uint dnsConn;  //dns最大并行连接数
  155.   
  156.   /** port on which is launched the http statistic webserver */
  157.   static unsigned short int httpPort;  //默认httpPort = 8081; 用通过web看Larbin抓取的统计情况
  158.   
  159.   /** port on which input wait for queries */
  160.   static unsigned short int inputPort;  //默认值是inputPort = 1976; 向Larbin添加url等输入信息的telnet接口
  161.   
  162.   /** parse configuration file */ //解析配置文件
  163.   static void parseFile (char *file);
  164.   
  165.   /** read the domain limit */
  166.   static void manageDomain (String &content, uint *pos);
  167.   
  168.   /** read the forbidden extensions */
  169.   static void manageExt (String &content, uint *pos);
  170.   
  171. };
  172. #endif // GLOBAL_H

 

全局变量类的CC文件

global.cc文件

 

 

 

 

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值