<div dir="ltr">Thank you very much. <div>And one more question, is there any checking mechanism for validity of config value?</div><div>For example, if config option "<span style="font-size:14px">maximum_object_size_in_</span><wbr style="font-size:14px"><span style="font-size:14px">memory</span>" is set as 10000, how to check if this value is valid?</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-22 0:52 GMT+08:00 Alex Rousskov <span dir="ltr"><<a href="mailto:rousskov@measurement-factory.com" target="_blank">rousskov@measurement-factory.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 02/21/2017 01:15 AM, 周书林 wrote:<br>
> I found the src/cf.data.pre file, and read the content. But I still want<br>
> to know how squid use this file to build the connection between the<br>
> config file and the source code.<br>
<br>
</span>As you already know, the parser is generated. The generated code either<br>
places parsed values directly into the global Config object or calls<br>
some helper functions that update the global state. (Updating global<br>
state during parsing is very wrong but that is a different story.)<br>
<br>
If you want to see the actual generated parsing code for a given<br>
squid.conf directive, just grep for it! For example,<br>
<br>
  $ fgrep -A5 -RI maximum_object_size_in_memory src<br>
<br>
will point you to the following code in src/cf_parser.cci:<br>
<br>
> src/cf_parser.cci:    if (!strcmp(token, "maximum_object_size_in_<wbr>memory")) {<br>
> src/cf_parser.cci:        cfg_directive = "maximum_object_size_in_<wbr>memory";<br>
> src/cf_parser.cci-        parse_b_size_t(&Config.Store.<wbr>maxInMemObjSize);<br>
> src/cf_parser.cci-        cfg_directive = NULL;<br>
> src/cf_parser.cci-        return 1;<br>
<br>
<br>
How was that code generated? Search for "cfg_directive = NULL" to find<br>
the parser generator code in the repository:<br>
<br>
  $ bzr grep 'cfg_directive = NULL'<br>
<br>
> src/cf_gen.cc:    fout << "        cfg_directive = NULL;" << std::endl;<br>
<br>
which will point you to the Entry::genParseAlias() method.<br>
<br>
<br>
HTH,<br>
<br>
Alex.<br>
<br>
<br>
<br>
> 2017-01-13 22:14 GMT+08:00 Stuart Henderson:<br>
><br>
>     On 2017-01-13, 周书林 <<a href="mailto:zhoushulin1992@gmail.com">zhoushulin1992@gmail.com</a><br>
<span class="">>     <mailto:<a href="mailto:zhoushulin1992@gmail.com">zhoushulin1992@gmail.<wbr>com</a>>> wrote:<br>
>     > Why some of the configuration directives in official website cannot find in<br>
>     > the source code? Some could find a relevant program variable in Class<br>
>     > SquidConfig, while majority of the configuration directives cannot be found<br>
>     > in the source code, for example , directive "announce_port".<br>
>     > So how does Squid parse the configuration file of Users, and use them in<br>
>     > the source code?<br>
><br>
>     The parser, sample config, etc, are all generated from src/cf.data.pre.<br>
><br>
><br>
>     ______________________________<wbr>_________________<br>
>     squid-dev mailing list<br>
</span>>     <a href="mailto:squid-dev@lists.squid-cache.org">squid-dev@lists.squid-cache.<wbr>org</a> <mailto:<a href="mailto:squid-dev@lists.squid-cache.org">squid-dev@lists.squid-<wbr>cache.org</a>><br>
>     <a href="http://lists.squid-cache.org/listinfo/squid-dev" rel="noreferrer" target="_blank">http://lists.squid-cache.org/<wbr>listinfo/squid-dev</a><br>
>     <<a href="http://lists.squid-cache.org/listinfo/squid-dev" rel="noreferrer" target="_blank">http://lists.squid-cache.org/<wbr>listinfo/squid-dev</a>><br>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> squid-dev mailing list<br>
> <a href="mailto:squid-dev@lists.squid-cache.org">squid-dev@lists.squid-cache.<wbr>org</a><br>
> <a href="http://lists.squid-cache.org/listinfo/squid-dev" rel="noreferrer" target="_blank">http://lists.squid-cache.org/<wbr>listinfo/squid-dev</a><br>
><br>
<br>
</div></div></blockquote></div><br></div>