<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>bianbian coding life</title>
	<link>http://bianbian.org</link>
	<description>便便代码人生: 关注技术, 翻译文档, 偶尔动动手</description>
	<pubDate>Tue, 12 Aug 2008 16:01:37 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>[哦] 深圳生活剪影</title>
		<link>http://bianbian.org/not-it/312.html</link>
		<comments>http://bianbian.org/not-it/312.html#comments</comments>
		<pubDate>Tue, 12 Aug 2008 16:01:37 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Not IT]]></category>

		<category><![CDATA[bianbian &amp; xuxu]]></category>

		<category><![CDATA[深圳]]></category>

		<guid isPermaLink="false">http://bianbian.org/not-it/312.html</guid>
		<description><![CDATA[今天单位运动会，深圳靠近热带，不得不说太阳实在太毒辣。呆了一下午，见光的部位就这样了（火辣辣地疼）：
&#169;2008 bianbian coding life. All Rights Reserved..
	标签: 深圳遵守创作共用协议，转载... ]]></description>
			<content:encoded><![CDATA[<p>今天单位运动会，深圳靠近热带，不得不说太阳实在太毒辣。呆了一下午，见光的部位就这样了（火辣辣地疼）：</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/%e6%b7%b1%e5%9c%b3" title="深圳" rel="tag">深圳</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/not-it/259.html" title="[转] 深圳空管站与深圳气象局将实现气象信息共享 (2008-02-23)">[转] 深圳空管站与深圳气象局将实现气象信息共享</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/not-it/312.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] ftp4j的解析list的bug及解决</title>
		<link>http://bianbian.org/technology/311.html</link>
		<comments>http://bianbian.org/technology/311.html#comments</comments>
		<pubDate>Thu, 19 Jun 2008 12:08:52 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[bug]]></category>

		<category><![CDATA[FTP]]></category>

		<category><![CDATA[ftp4j]]></category>

		<category><![CDATA[解决]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/311.html</guid>
		<description><![CDATA[上次推荐的ftp4j在解析部分FTP站点的目录list的时候遇到了FTPListParseException（也怪FTP协议没有对LIST格式作出标准）。查看源码发现，主要是两个问题：
1）文件权限不只rwx这三个，附加了s、t（详... ]]></description>
			<content:encoded><![CDATA[<p>上次<a href="http://bianbian.org/technology/294.html" target=_blank>推荐的ftp4j</a>在解析部分FTP站点的目录list的时候遇到了FTPListParseException（也怪FTP协议没有对LIST格式作出标准）。查看源码发现，主要是两个问题：<br />
1）文件权限不只rwx这三个，附加了s、t（详见<a href="http://en.wikipedia.org/wiki/File_system_permissions" target=_blank>http://en.wikipedia.org/wiki/File_system_permissions</a>）<br />
2）部分ftpd似乎直接调用的“ls -l”输出目录，第一行是“total xxx”<br />
给作者写信了，说不定下个版本就有Sepcial Thanks to bianbian 了。嘿嘿嘿嘿。。。<br />
修正后的代码（省略后面没有变化的部分）：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">public</span><span style="color: Gray;"> </span><span style="color: Green;">class</span><span style="color: Gray;"> </span><span style="color: Blue;">UnixListParser</span><span style="color: Gray;"> </span><span style="color: Green;">implements</span><span style="color: Gray;"> </span><span style="color: Blue;">FTPListParser</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">// bianbian.org: Pattern有问题，修正</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">private</span><span style="color: Gray;">&nbsp;</span><span class="hl-types">static</span><span style="color: Gray;"> </span><span class="hl-types">final</span><span style="color: Gray;"> </span><span style="color: Blue;">Pattern</span><span style="color: Gray;"> </span><span style="color: Blue;">PATTERN</span><span style="color: Gray;"> = </span><span style="color: Blue;">Pattern</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .</span><span style="color: Blue;">compile</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^([dlcbsp</span><span style="color: Navy;">\\</span><span style="color: Red;">-])[r</span><span style="color: Navy;">\\</span><span style="color: Red;">-][w</span><span style="color: Navy;">\\</span><span style="color: Red;">-][xsS</span><span style="color: Navy;">\\</span><span style="color: Red;">-][r</span><span style="color: Navy;">\\</span><span style="color: Red;">-][w</span><span style="color: Navy;">\\</span><span style="color: Red;">-][xsS</span><span style="color: Navy;">\\</span><span style="color: Red;">-][r</span><span style="color: Navy;">\\</span><span style="color: Red;">-][w</span><span style="color: Navy;">\\</span><span style="color: Red;">-][xtT</span><span style="color: Navy;">\\</span><span style="color: Red;">-]</span><span style="color: Navy;">\\</span><span style="color: Red;">s+</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">(?:</span><span style="color: Navy;">\\</span><span style="color: Red;">d+</span><span style="color: Navy;">\\</span><span style="color: Red;">s+)?</span><span style="color: Navy;">\\</span><span style="color: Red;">S+</span><span style="color: Navy;">\\</span><span style="color: Red;">s*</span><span style="color: Navy;">\\</span><span style="color: Red;">S+</span><span style="color: Navy;">\\</span><span style="color: Red;">s+(</span><span style="color: Navy;">\\</span><span style="color: Red;">d+)</span><span style="color: Navy;">\\</span><span style="color: Red;">s+(?:(</span><span style="color: Navy;">\\</span><span style="color: Red;">w{3})</span><span style="color: Navy;">\\</span><span style="color: Red;">s+(</span><span style="color: Navy;">\\</span><span style="color: Red;">d{1,2}))</span><span style="color: Navy;">\\</span><span style="color: Red;">s+</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">(?:(</span><span style="color: Navy;">\\</span><span style="color: Red;">d{4})|(?:(</span><span style="color: Navy;">\\</span><span style="color: Red;">d{1,2}):(</span><span style="color: Navy;">\\</span><span style="color: Red;">d{1,2})))</span><span style="color: Navy;">\\</span><span style="color: Red;">s+</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">([^</span><span style="color: Navy;">\\\\</span><span style="color: Red;">/*?</span><span style="color: Navy;">\&quot;</span><span style="color: Red;">&lt;&gt;|]+)(?: -&gt; ([^</span><span style="color: Navy;">\\\\</span><span style="color: Red;">*?</span><span style="color: Navy;">\&quot;</span><span style="color: Red;">&lt;&gt;|]+))?$</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">private</span><span style="color: Gray;">&nbsp;</span><span class="hl-types">static</span><span style="color: Gray;"> </span><span class="hl-types">final</span><span style="color: Gray;"> </span><span style="color: Blue;">DateFormat</span><span style="color: Gray;"> </span><span style="color: Blue;">DATE_FORMAT</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">SimpleDateFormat</span><span style="color: Olive;">(</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">MMM dd yyyy HH:mm</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">Locale</span><span style="color: Gray;">.</span><span style="color: Blue;">US</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">public</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">FTPFile</span><span style="color: Olive;">[]</span><span style="color: Gray;"> </span><span style="color: Blue;">parse</span><span style="color: Olive;">(</span><span style="color: Blue;">String</span><span style="color: Olive;">[]</span><span style="color: Gray;"> </span><span style="color: Blue;">lines</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Green;">throws</span><span style="color: Gray;"> </span><span style="color: Blue;">FTPListParseException</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">int</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">currentYear</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">GregorianCalendar</span><span style="color: Olive;">()</span><span style="color: Gray;">.</span><span style="color: Blue;">get</span><span style="color: Olive;">(</span><span style="color: Blue;">Calendar</span><span style="color: Gray;">.</span><span style="color: Blue;">YEAR</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">int</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">i</span><span style="color: Gray;">, </span><span style="color: Blue;">jump</span><span style="color: Gray;"> = </span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">size</span><span style="color: Gray;"> = </span><span style="color: Blue;">lines</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//bianbian.org: glftpd 的第一行和 ls -l 一样，会丢个&quot;total N&quot;过来，先去掉</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">size</span><span style="color: Gray;"> &gt; </span><span style="color: Maroon;">0</span><span style="color: Gray;"> &amp;&amp; </span><span style="color: Blue;">lines</span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">startsWith</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">total</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">))</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">size</span><span style="color: Gray;">--;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">jump</span><span style="color: Gray;"> = </span><span style="color: Maroon;">1</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">FTPFile</span><span style="color: Olive;">[]</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">ret</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">FTPFile</span><span style="color: Olive;">[</span><span style="color: Blue;">size</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">for</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Gray;"> = </span><span style="color: Maroon;">0</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;"> &lt; </span><span style="color: Blue;">size</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">++</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">Matcher</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">m</span><span style="color: Gray;"> = </span><span style="color: Blue;">PATTERN</span><span style="color: Gray;">.</span><span style="color: Blue;">matcher</span><span style="color: Olive;">(</span><span style="color: Blue;">lines</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Gray;"> + </span><span style="color: Blue;">jump</span><span style="color: Olive;">])</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">matches</span><span style="color: Olive;">())</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">ret</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">FTPFile</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// Retrieve the data.</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="hl-types">char</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">typeChar</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">1</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">charAt</span><span style="color: Olive;">(</span><span style="color: Maroon;">0</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">sizeString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">2</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">monthString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">3</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">dayString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">4</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">yearString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">5</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">hourString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">6</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">minuteString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">7</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">nameString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">8</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">String</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">linkedString</span><span style="color: Gray;"> = </span><span style="color: Blue;">m</span><span style="color: Gray;">.</span><span style="color: Blue;">group</span><span style="color: Olive;">(</span><span style="color: Maroon;">9</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// Parse the data.</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">-cbsp</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">.</span><span style="color: Blue;">indexOf</span><span style="color: Olive;">(</span><span style="color: Blue;">typeChar</span><span style="color: Olive;">)</span><span style="color: Gray;"> &gt; -</span><span style="color: Maroon;">1</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">ret</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">setType</span><span style="color: Olive;">(</span><span style="color: Blue;">FTPFile</span><span style="color: Gray;">.</span><span style="color: Blue;">TYPE_FILE</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">typeChar</span><span style="color: Gray;"> == </span><span style="color: #8b0000;">'</span><span style="color: Red;">d</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">ret</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">setType</span><span style="color: Olive;">(</span><span style="color: Blue;">FTPFile</span><span style="color: Gray;">.</span><span style="color: Blue;">TYPE_DIRECTORY</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">typeChar</span><span style="color: Gray;"> == </span><span style="color: #8b0000;">'</span><span style="color: Red;">l</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">ret</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">setType</span><span style="color: Olive;">(</span><span style="color: Blue;">FTPFile</span><span style="color: Gray;">.</span><span style="color: Blue;">TYPE_LINK</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">ret</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">.</span><span style="color: Blue;">setLink</span><span style="color: Olive;">(</span><span style="color: Blue;">linkedString</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">throw</span><span style="color: Gray;">&nbsp;</span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">FTPListParseException</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; ...</span></li></ol></div>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/bug" title="bug" rel="tag">bug</a>, <a href="http://bianbian.org/tag/ftp" title="FTP" rel="tag">FTP</a>, <a href="http://bianbian.org/tag/ftp4j" title="ftp4j" rel="tag">ftp4j</a>, <a href="http://bianbian.org/tag/%e8%a7%a3%e5%86%b3" title="解决" rel="tag">解决</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/20.html" title="[原] 解决UltraEdit在UTF-8编码上的bug (2006-09-06)">[原] 解决UltraEdit在UTF-8编码上的bug</a> (9)</li>
	<li><a href="http://bianbian.org/technology/294.html" title="[原] 强烈推荐一个纯java的FTP Client库：ftp4j (2008-04-15)">[原] 强烈推荐一个纯java的FTP Client库：ftp4j</a> (2)</li>
	<li><a href="http://bianbian.org/technology/280.html" title="[原] IDL剪贴板绘图在其他语言调用下失效的bug (2008-03-26)">[原] IDL剪贴板绘图在其他语言调用下失效的bug</a> (0)</li>
	<li><a href="http://bianbian.org/technology/130.html" title="[原]C#里更改控件的显示Z顺序 (2007-03-01)">[原]C#里更改控件的显示Z顺序</a> (2)</li>
	<li><a href="http://bianbian.org/technology/222.html" title="[晕] nginx的internal属性的bug (2007-10-16)">[晕] nginx的internal属性的bug</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/311.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[啊] 好久没更新了，I&#8217;m back now!</title>
		<link>http://bianbian.org/not-it/310.html</link>
		<comments>http://bianbian.org/not-it/310.html#comments</comments>
		<pubDate>Tue, 03 Jun 2008 02:25:44 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Not IT]]></category>

		<category><![CDATA[照片]]></category>

		<guid isPermaLink="false">http://bianbian.org/not-it/310.html</guid>
		<description><![CDATA[都在忙一件事情：

&#169;2008 bianbian coding life. All Rights Reserved..
	标签: 照片遵守创作共用协议，转载请链接形式注明来自http://bianbian.org 做人要厚道

	相关日志
	
	[嗯]咱也到过首都了。。。 (1)
	[... ]]></description>
			<content:encoded><![CDATA[<p>都在忙一件事情：<br />
<img src='http://bianbian.org/wp-content/uploads/2008/06/bianbian_master.PNG' alt='bianbian_master.PNG' /></p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/%e7%85%a7%e7%89%87" title="照片" rel="tag">照片</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/not-it/180.html" title="[补]上次去四川出差的照片 (2007-06-15)">[补]上次去四川出差的照片</a> (0)</li>
	<li><a href="http://bianbian.org/not-it/entertainment/97.html" title="[哈]圣诞节奖了个数码相机，^_^ (2006-12-25)">[哈]圣诞节奖了个数码相机，^_^</a> (7)</li>
	<li><a href="http://bianbian.org/not-it/163.html" title="[哈]珍珠泉还不错噢~~ (2007-04-19)">[哈]珍珠泉还不错噢~~</a> (4)</li>
	<li><a href="http://bianbian.org/not-it/105.html" title="[嗯]听说我变胖了 (2007-01-10)">[嗯]听说我变胖了</a> (3)</li>
	<li><a href="http://bianbian.org/not-it/115.html" title="[嗯]嘘嘘照片。:) (2007-01-29)">[嗯]嘘嘘照片。:)</a> (3)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/not-it/310.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[转] 民航气象区域预警预报</title>
		<link>http://bianbian.org/not-it/308.html</link>
		<comments>http://bianbian.org/not-it/308.html#comments</comments>
		<pubDate>Wed, 21 May 2008 08:02:47 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Meteorology]]></category>

		<category><![CDATA[Not IT]]></category>

		<category><![CDATA[区域预警]]></category>

		<category><![CDATA[民航]]></category>

		<category><![CDATA[气象]]></category>

		<guid isPermaLink="false">http://bianbian.org/not-it/308.html</guid>
		<description><![CDATA[    随着我国民航运输业的迅猛发展，区域预警预报的作用日益突显，对此项技术的研究已成为迫在眉睫的任务。民航气象系统应加强综合立体探测系统的建设，加快精细化航空数值预报系统的... ]]></description>
			<content:encoded><![CDATA[<p>    随着我国民航运输业的迅猛发展，区域预警预报的作用日益突显，对此项技术的研究已成为迫在眉睫的任务。民航气象系统应加强综合立体探测系统的建设，加快精细化航空数值预报系统的建设，通过加强实时探测资料的联网应用、建立航空危险天气要素预警预报模型和资料共享平台等手段，提高危险天气的预警和临近预报水平，为保障飞行安全、提高空域容量、提升运行效率提供辅助决策工具。</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/%e5%8c%ba%e5%9f%9f%e9%a2%84%e8%ad%a6" title="区域预警" rel="tag">区域预警</a>, <a href="http://bianbian.org/tag/%e6%b0%91%e8%88%aa" title="民航" rel="tag">民航</a>, <a href="http://bianbian.org/tag/%e6%b0%94%e8%b1%a1" title="气象" rel="tag">气象</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/not-it/259.html" title="[转] 深圳空管站与深圳气象局将实现气象信息共享 (2008-02-23)">[转] 深圳空管站与深圳气象局将实现气象信息共享</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/not-it/308.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] gmail真是太强悍了！！！</title>
		<link>http://bianbian.org/technology/307.html</link>
		<comments>http://bianbian.org/technology/307.html#comments</comments>
		<pubDate>Thu, 15 May 2008 16:30:40 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[gmail]]></category>

		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/307.html</guid>
		<description><![CDATA[今天偶然又发现一个gmail强悍的功能：
把exe文件改名为doc，比如cmd.exe.doc，然后当附件上载。（因为不允许直接上载exe）
然后收到以后因为是doc结尾，会列出“在 HTML 格式下查看 以 Google 文档... ]]></description>
			<content:encoded><![CDATA[<p>今天偶然又发现一个gmail强悍的功能：<br />
把exe文件改名为doc，比如cmd.exe.doc，然后当附件上载。（因为不允许直接上载exe）<br />
然后收到以后因为是doc结尾，会列出“在 HTML 格式下查看 以 Google 文档打开 下载”功能，这时候点了“在HTML格式下查看”。我想出个乱码应该是常理。<br />
结果，强悍的gmail取出了exe里的格式信息（exe由几个段构成，详细请查询exe文件格式，此不赘述）：<br />
WINDOWS EXECUTABLE<br />
32bit for Windows 95 and Windows NT<br />
Technical File Information:<br />
Image File Header<br />
&#8230;.<br />
Image Optional Header<br />
&#8230;.<br />
Import Table<br />
&#8230;.<br />
Section Table<br />
&#8230;.<br />
Header Information<br />
&#8230;.<br />
太强悍了~~~一个email系统能做到这个份上，google怎能不强大~~~</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/gmail" title="gmail" rel="tag">gmail</a>, <a href="http://bianbian.org/tag/google" title="google" rel="tag">google</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/255.html" title="[晕] 发现gmail的问题 (2008-02-20)">[晕] 发现gmail的问题</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/307.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] Shibboleth 2.0 Identity Provider (IdP) LDAP认证配置指南</title>
		<link>http://bianbian.org/technology/306.html</link>
		<comments>http://bianbian.org/technology/306.html#comments</comments>
		<pubDate>Wed, 14 May 2008 05:15:19 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[IdP]]></category>

		<category><![CDATA[LDAP]]></category>

		<category><![CDATA[Shibboleth]]></category>

		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/306.html</guid>
		<description><![CDATA[首先佩服老外：1）把简单的东西搞得很复杂 2）很会创造标准和协议
这次遇到的Shibboleth就是这么个东西，看了两天英文，对人为复杂、创造协议痛恨中。简单写个配置指南，给其他人做个参考... ]]></description>
			<content:encoded><![CDATA[<p>首先佩服老外：1）把简单的东西搞得很复杂 2）很会创造标准和协议<br />
这次遇到的Shibboleth就是这么个东西，看了两天英文，对人为复杂、创造协议痛恨中。简单写个配置指南，给其他人做个参考，少走弯路。</p>
<p>注意：<br />
1) 系统时间必须设置正确<br />
2) apache 需要 mod_ssl mod_proxy_ajp，假设安装在 /etc/httpd<br />
3) 必须使用 tomcat-5.5.x+，假设安装在 /opt/apache-tomcat-5.5.26<br />
4) 如果需要改变安装目录重新安装，必须退到解压那步（否则很多和目录有关的代码不会重新编译，导致严重错误&#8211;啊！我整整一天的痛苦啊！）</p>
<p># 取消tomcat的AJP身份认证<br />
vi /opt/apache-tomcat-5.5.26/conf/server.xml<br />
# 找到 Define an AJP 1.3 Connector 那，初始为：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">Connector</span><span style="color: Gray;"> </span><span style="color: #00008b;">port</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">8009</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">enableLookups</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">redirectPort</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">8443</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">protocol</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">AJP/1.3</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p># 修改为（端口改变没有特殊目的，只是我系统上跑了好几个tomcat，防止冲突）：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">Connector</span><span style="color: Gray;"> </span><span style="color: #00008b;">port</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">8019</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">enableLookups</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">redirectPort</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">8443</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">protocol</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">AJP/1.3</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">request</span><span style="color: Gray;">.</span><span style="color: #00008b;">tomcatAuthentication</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">address</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">127.0.0.1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p># apache httpd 配置AJP反向代理<br />
vi /etc/httpd/conf.d/proxy_ajp.conf<br />
# 添加：<br />
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so<br />
ProxyPass /idp/ ajp://localhost:8019/idp/</p>
<p># 安装Shibboleth 2.0 Identity Provider (IdP)<br />
unzip shibboleth-idp-2.0.0-bin.zip<br />
cd identityprovider<br />
cp endorsed/*.jar /opt/apache-tomcat-5.5.26/common/endorsed/<br />
sh ant.sh install<br />
# 提示是否新安装，yes<br />
# 提示选择安装目录，/opt/idp<br />
# 提示hostname，根据实际填写<br />
# 提示加密密匙，随便写</p>
<p># 部署war<br />
vi /opt/apache-tomcat-5.5.26/conf/Catalina/localhost/idp.xml<br />
# 内容：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;?</span><span style="color: Green;">xml</span><span style="color: Gray;"> </span><span style="color: #00008b;">version</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1.0</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">encoding</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">UTF-8</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">?&gt;</span></li>
<li><span style="color: Olive;">&lt;</span><span style="color: Green;">Context</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">docBase</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/opt/idp/war/idp.war</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">privileged</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">true</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">antiResourceLocking</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">antiJARLocking</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">unpackWAR</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p># 测试：应该能看到“ok”<br />
httpd -k restart<br />
links http://127.0.0.1/idp/profile/Status</p>
<p># 配置用户名/密码认证方式<br />
vi /opt/idp/conf/handler.xml<br />
# 找到 Login Handlers 那，注释掉&#8221;RemoteUser&#8221;认证方式，启用UsernamePassword方式。修改为：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">LoginHandler</span><span style="color: Gray;"> </span><span style="color: #00008b;">xsi:type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">UsernamePassword</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">jaasConfigurationLocation</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">file:///opt/idp/conf/login.config</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">AuthenticationMethod</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">AuthenticationMethod</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">AuthenticationMethod</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">AuthenticationMethod</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">LoginHandler</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p># 配置LDAP连接方式<br />
vi /opt/idp/conf/login.config</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">ShibUserPassAuth {</li>
<li>&nbsp;&nbsp; edu.vt.middleware.ldap.jaas.LdapLoginModule required</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;host=&quot;ldap.bianbian.org&quot;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;base=&quot;dc=test,dc=bianbian,dc=org&quot;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;serviceUser=&quot;cn=Directory Manager&quot;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;serviceCredential=&quot;11111111&quot;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;subtreeSearch=&quot;true&quot;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp;userField=&quot;uid&quot;;</li>
<li>};</li></ol></div>
<p># 配置SP（关键！加入SP的Metadata描述）<br />
vi /opt/idp/conf/relying-party.xml<br />
# 找到 MetadataProvider 那，注意修改id和backingFile要不同<br />
# 假设某通过apache模块工作的SP位于 http://bianbian.org/</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">MetadataProvider</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">URLMD</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">xsi:type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">FileBackedHTTPMetadataProvider</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">xmlns</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">urn:mace:shibboleth:2.0:metadata</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">metadataURL</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://bianbian.org/Shibboleth.sso/Metadata</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">backingFile</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/opt/idp/metadata/bianbian.org-metadata.xml</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p># 配置传递属性，这跟每个SP有关，要与SP联合配置</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/apache" title="apache" rel="tag">apache</a>, <a href="http://bianbian.org/tag/idp" title="IdP" rel="tag">IdP</a>, <a href="http://bianbian.org/tag/ldap" title="LDAP" rel="tag">LDAP</a>, <a href="http://bianbian.org/tag/shibboleth" title="Shibboleth" rel="tag">Shibboleth</a>, <a href="http://bianbian.org/tag/tomcat" title="tomcat" rel="tag">tomcat</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/55.html" title="[原]apache模块的编写实例 (反向透明代理实现方式之一) (2006-10-30)">[原]apache模块的编写实例 (反向透明代理实现方式之一)</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/306.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[呵] 好久没叠沙拉了，这次叠了个尽兴</title>
		<link>http://bianbian.org/not-it/304.html</link>
		<comments>http://bianbian.org/not-it/304.html#comments</comments>
		<pubDate>Sat, 10 May 2008 13:23:50 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Not IT]]></category>

		<category><![CDATA[bianbian &amp; xuxu]]></category>

		<category><![CDATA[pizzahut]]></category>

		<category><![CDATA[必胜客]]></category>

		<category><![CDATA[沙拉]]></category>

		<guid isPermaLink="false">http://bianbian.org/not-it/304.html</guid>
		<description><![CDATA[  
用了2罐黄瓜（这次的黄瓜实在太小，中间停工一次，等店里补充），1罐菠萝（菠萝只剩残渣，因此中间不整齐），2罐黄桃（中间全是黄桃，哈哈哈哈）
&#169;2008 bianbian coding life. All Rights Reser... ]]></description>
			<content:encoded><![CDATA[<p><a href='http://bianbian.org/wp-content/uploads/2008/05/pizzahut_174.jpg' title='pizzahut_174.jpg' target=_img><img src='http://bianbian.org/wp-content/uploads/2008/05/pizzahut_174.thumbnail.jpg' alt='pizzahut_174.jpg' /></a>  <a href='http://bianbian.org/wp-content/uploads/2008/05/pizzahut_176.jpg' title='pizzahut_174.jpg' target=_img><img src='http://bianbian.org/wp-content/uploads/2008/05/pizzahut_176.thumbnail.jpg' alt='pizzahut_176.jpg' /></a><br />
用了2罐黄瓜（这次的黄瓜实在太小，中间停工一次，等店里补充），1罐菠萝（菠萝只剩残渣，因此中间不整齐），2罐黄桃（中间全是黄桃，哈哈哈哈）</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/pizzahut" title="pizzahut" rel="tag">pizzahut</a>, <a href="http://bianbian.org/tag/%e5%bf%85%e8%83%9c%e5%ae%a2" title="必胜客" rel="tag">必胜客</a>, <a href="http://bianbian.org/tag/%e6%b2%99%e6%8b%89" title="沙拉" rel="tag">沙拉</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/not-it/48.html" title="[哈]第一次叠沙拉 (2006-10-22)">[哈]第一次叠沙拉</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/not-it/304.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] 给LilyBBS新增源代码语法高亮功能</title>
		<link>http://bianbian.org/technology/javascript/300.html</link>
		<comments>http://bianbian.org/technology/javascript/300.html#comments</comments>
		<pubDate>Tue, 06 May 2008 13:12:56 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[BBS]]></category>

		<category><![CDATA[Lily]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/javascript/300.html</guid>
		<description><![CDATA[原文：[公告] WEB新增源代码语法高亮功能
使用方法：
[code]
代码
[/code]
目前支持：C/C++、Java、Python、Bash、SQL、HTML、XML、CSS、Javascript、Makefile、Ruby、PHP、Awk、Perl
效果示例：#include &#60;stdio.h&#62;i... ]]></description>
			<content:encoded><![CDATA[<p>原文：<a href="http://lilybbs.net/bbstcon?board=sysop&#038;file=M.1210049875.A" target=_blank>[公告] WEB新增源代码语法高亮功能</a></p>
<p>使用方法：<br />
[code]<br />
代码<br />
[/code]</p>
<p>目前支持：C/C++、Java、Python、Bash、SQL、HTML、XML、CSS、Javascript、Makefile、Ruby、PHP、Awk、Perl</p>
<p>效果示例：<PRE class=prettyprint><SPAN class=com>#include &lt;stdio.h&gt;</SPAN><SPAN class=pln><BR></SPAN><SPAN class=kwd>int</SPAN><SPAN class=pln> main</SPAN><SPAN class=pun>()</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>{</SPAN><SPAN class=pln><BR>&nbsp; &nbsp; printf</SPAN><SPAN class=pun>(</SPAN><SPAN class=str>&#8220;Many people think they are full of niubility,&#8221;</SPAN><SPAN class=pun>);</SPAN><SPAN class=pln><BR></SPAN><SPAN class=pun>}</SPAN></PRE><br />
<PRE class=prettyprint><SPAN class=kwd>import</SPAN><SPAN class=pln> org</SPAN><SPAN class=pun>.</SPAN><SPAN class=pln>bianbian</SPAN><SPAN class=pun>.</SPAN><SPAN class=pln>code</SPAN><SPAN class=pun>;</SPAN><SPAN class=pln><BR></SPAN><SPAN class=kwd>class</SPAN><SPAN class=pln> </SPAN><SPAN class=typ>CodeTest</SPAN><SPAN class=pun>()</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>{</SPAN><SPAN class=pln><BR>&nbsp; &nbsp; </SPAN><SPAN class=kwd>public</SPAN><SPAN class=pln> </SPAN><SPAN class=kwd>static</SPAN><SPAN class=pln> </SPAN><SPAN class=kwd>void</SPAN><SPAN class=pln> main</SPAN><SPAN class=pun>(</SPAN><SPAN class=typ>String</SPAN><SPAN class=pun>[]</SPAN><SPAN class=pln> args</SPAN><SPAN class=pun>)</SPAN><SPAN class=pln> </SPAN><SPAN class=pun>{</SPAN><SPAN class=pln><BR>&nbsp; &nbsp; &nbsp; &nbsp; </SPAN><SPAN class=typ>System</SPAN><SPAN class=pun>.</SPAN><SPAN class=kwd>out</SPAN><SPAN class=pun>.</SPAN><SPAN class=pln>println</SPAN><SPAN class=pun>(</SPAN><SPAN class=str>&#8220;and like to play zhuangbility,&#8221;</SPAN><SPAN class=pun>);</SPAN><SPAN class=pln><BR>&nbsp; &nbsp; </SPAN><SPAN class=pun>}</SPAN><SPAN class=pln><BR></SPAN><SPAN class=pun>}</SPAN></PRE><br />
<PRE class=prettyprint><SPAN class=pun>&lt;?</SPAN><SPAN class=pln>php<BR>&nbsp; &nbsp; echo </SPAN><SPAN class=str>&#8216;which only reflect their shability.&#8217;</SPAN><SPAN class=pun>;</SPAN><SPAN class=pln><BR></SPAN><SPAN class=pun>?&gt;</SPAN></PRE></p>
<p>采用的是<a href="http://code.google.com/p/google-code-prettify/" target=_blank>prettify</a>，为LilyBBS的客户端解析UBB做了点修改。推荐一下，还是挺好用的。</p>
<style>.str { color: #080; } .kwd { color: #008; font-weight: bold; } .com { color: #800; } .typ { color: #606; font-weight: bold; } .lit { color: #066; } .pun { color: #660; } .pln { color: #000; } .tag { color: #008; font-weight: bold; } .atn { color: #606; } .atv { color: #080; } .dec { color: #606; } pre.prettyprint { font-family:Courier New,Fixdays,宋体; margin: 0 20px 0 20px; padding: 1px; border: 1px solid #ccc; }</style>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/bbs" title="BBS" rel="tag">BBS</a>, <a href="http://bianbian.org/tag/lily" title="Lily" rel="tag">Lily</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/javascript/263.html" title="[原] 整理了BBS的Javascript脚本，注意关键字 (2008-02-29)">[原] 整理了BBS的Javascript脚本，注意关键字</a> (2)</li>
	<li><a href="http://bianbian.org/technology/285.html" title="[原] BBS日志和点击率的优化方向及静态化 (2008-04-06)">[原] BBS日志和点击率的优化方向及静态化</a> (0)</li>
	<li><a href="http://bianbian.org/technology/javascript/286.html" title="[原] 关于web访问小百合BBS的脚本问题 (2008-04-07)">[原] 关于web访问小百合BBS的脚本问题</a> (28)</li>
	<li><a href="http://bianbian.org/technology/283.html" title="[原] 未来分布式BBS的可能实现架构 (2008-04-04)">[原] 未来分布式BBS的可能实现架构</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/javascript/300.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] solr 1.3 multicore使用指南</title>
		<link>http://bianbian.org/technology/299.html</link>
		<comments>http://bianbian.org/technology/299.html#comments</comments>
		<pubDate>Mon, 05 May 2008 02:42:51 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Lucene]]></category>

		<category><![CDATA[solr]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/299.html</guid>
		<description><![CDATA[尽管solr 1.3还是dev版，目前还没release，它比1.2多的很多特性（特别是multicore的支持）还是让我选择了1.3（1.2用了一段时间，多个索引要复制多份，非常麻烦）。
使用基本和solr 1.2差不多，几乎... ]]></description>
			<content:encoded><![CDATA[<p>尽管solr 1.3还是dev版，目前还没release，它比1.2多的很多特性（特别是multicore的支持）还是让我选择了1.3（1.2用了一段时间，多个索引要复制多份，非常麻烦）。<br />
使用基本和solr 1.2差不多，几乎没什么难度就切换到1.3了。只是多了multicore的配置：<br />
solr/home比如设为/opt/solrs<br />
在/opt/solrs下新建multicore.xml</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;?</span><span style="color: Green;">xml</span><span style="color: Gray;"> </span><span style="color: #00008b;">version</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1.0</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">encoding</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">UTF-8</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">?&gt;</span></li>
<li><span style="color: Olive;">&lt;</span><span style="color: Green;">multicore</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">adminPath</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/admin/multicore</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">persistent</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">true</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">sharedLib</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">lib</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">core</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">core0</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">instanceDir</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">core0</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">default</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">true</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">core</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">core1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">instanceDir</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">core1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">multicore</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>默认跑了，发现索引数据存放目录dataDir全跑到web-app容器的./solr/data目录下去了。。。。要知道multicore最关键的就是dataDir要不同。。。<br />
参考wiki：<a href="http://wiki.apache.org/solr/MultiCore" target=_blank>MultiCore</a><br />
上面说可以在core里加dataDir属性，于是加上，测试。ft，还是没用。<br />
于是看solr源码，发现上面dataDir的部分根本没有读取（至少今天我svn check出来的代码里面没有，汗）。<br />
于是跟踪源码，发现new SolrCore的时候dataDir为null，如果为null，则从SolrConfig中读取。<br />
看到这里，知道原来得在SolrConfig中设置dataDir才行。那么SolrConfig是什么呢，就是对应到配置文件conf/solrconfig.xml：<br />
第29行：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">&lt;!-- Used to specify an alternate directory to hold all index data</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp;&nbsp; other than the default ./data under the Solr home.</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp;&nbsp; If replication is in use, this should match the replication configuration. --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">dataDir</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">${solr.data.dir:./solr/data}</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">dataDir</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>终于发现居然在这里设置。把这行注释掉，就默认在core/data下了。。。。<br />
配置方式比较汗，我觉得应该支持直接在multicore.xml里设置dataDir（按wiki说明，solr 1.3也是这样想的，不过目前的dev版本未实现）。</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/java" title="Java" rel="tag">Java</a>, <a href="http://bianbian.org/tag/lucene" title="Lucene" rel="tag">Lucene</a>, <a href="http://bianbian.org/tag/solr" title="solr" rel="tag">solr</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/88.html" title="[译]volatile关键字有什么用？ (2006-12-13)">[译]volatile关键字有什么用？</a> (3)</li>
	<li><a href="http://bianbian.org/technology/74.html" title="[嗯]OSCache很不错啊 (2006-11-07)">[嗯]OSCache很不错啊</a> (0)</li>
	<li><a href="http://bianbian.org/technology/84.html" title="[原]Java正则表达式获取匹配结果 (2006-12-02)">[原]Java正则表达式获取匹配结果</a> (0)</li>
	<li><a href="http://bianbian.org/technology/297.html" title="[原] spring的事件监听和java反射及IoC注入还是很强大的 (2008-04-25)">[原] spring的事件监听和java反射及IoC注入还是很强大的</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/299.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] IDL的格式化字符串太让人faint了</title>
		<link>http://bianbian.org/technology/298.html</link>
		<comments>http://bianbian.org/technology/298.html#comments</comments>
		<pubDate>Thu, 01 May 2008 13:25:00 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[ENVI &amp; IDL]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[IDL]]></category>

		<category><![CDATA[格式]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/298.html</guid>
		<description><![CDATA[也许跟FORTRAN差不多，那也是我为什么讨厌FORTRAN最大的原因
比如我要输出 YY-MM-DD hh_mm_ss 的时间格式：

IDL> PRINT, FORMAT= $
IDL>   '(C(CYI2.2,"-",CMOI2.2,"-",CDI2.2,CHI3.2,"_",CMI2.2,"_",CSI2.2))', $
IDL>   SYSTIME(/JULIA... ]]></description>
			<content:encoded><![CDATA[<p>也许跟FORTRAN差不多，那也是我为什么讨厌FORTRAN最大的原因</p>
<p>比如我要输出 YY-MM-DD hh_mm_ss 的时间格式：<br />
<code><br />
IDL> PRINT, FORMAT= $<br />
IDL>   '(C(CYI2.2,"-",CMOI2.2,"-",CDI2.2,CHI3.2,"_",CMI2.2,"_",CSI2.2))', $<br />
IDL>   SYSTIME(/JULIAN)<br />
</code><br />
OMG&#8230;..Orz&#8230;&#8230;</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/format" title="format" rel="tag">format</a>, <a href="http://bianbian.org/tag/idl" title="IDL" rel="tag">IDL</a>, <a href="http://bianbian.org/tag/%e6%a0%bc%e5%bc%8f" title="格式" rel="tag">格式</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/280.html" title="[原] IDL剪贴板绘图在其他语言调用下失效的bug (2008-03-26)">[原] IDL剪贴板绘图在其他语言调用下失效的bug</a> (0)</li>
	<li><a href="http://bianbian.org/technology/273.html" title="[原] IDL的数组存储是行顺序，下标引用是列在前 (2008-03-17)">[原] IDL的数组存储是行顺序，下标引用是列在前</a> (1)</li>
	<li><a href="http://bianbian.org/technology/266.html" title="[原] IDL 7.0测试截图 (2008-03-08)">[原] IDL 7.0测试截图</a> (0)</li>
	<li><a href="http://bianbian.org/technology/274.html" title="[原] 自定义IDL调色板指南 (2008-03-21)">[原] 自定义IDL调色板指南</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/298.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] spring的事件监听和java反射及IoC注入还是很强大的</title>
		<link>http://bianbian.org/technology/297.html</link>
		<comments>http://bianbian.org/technology/297.html#comments</comments>
		<pubDate>Fri, 25 Apr 2008 13:16:02 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[IoC]]></category>

		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/297.html</guid>
		<description><![CDATA[这几天做了一个东西：在DAO上往数据库插入一个bean的时候，用java反射机制自动产生SQL语句，同时publishEvent触发bean更新事件，事件监听类根据配置文件处理bean并自动提交到Lucene（Solr）全文检索... ]]></description>
			<content:encoded><![CDATA[<p>这几天做了一个东西：在DAO上往数据库插入一个bean的时候，用java反射机制自动产生SQL语句，同时publishEvent触发bean更新事件，事件监听类根据配置文件处理bean并自动提交到Lucene（Solr）全文检索（主要是bean的属性跟Solr字段的对应）进行准实时的索引更新（当然bean有缓冲）；反过来，检索结果有望自动转成bean丢给用户callback。<br />
danny这个巨牛完成的基于spring的再次开发框架除了自动controller Action绑定、ResultSet自动转成bean、自动分页、自动View视图等等快捷开发功能外（Orz），现在支持自动全文检索了，而且整个过程对其他开发人员是无缝过渡的，建立全文索引不需要修改任何一处代码（其实概念上用AOP比事件监听更适合：“可热插拔”的全文检索切面，但是事件监听最大的优势是异步的，全文检索准实时索引更新这种需求用AOP同步包装一层实在是太不实际了）：只要在配置文件里指定哪些数据表的bean哪些字段需要全文检索，OK。。。添加或者全记录更新的时候索引都会准实时更新——而且几乎近似热插拔。</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/ioc" title="IoC" rel="tag">IoC</a>, <a href="http://bianbian.org/tag/java" title="Java" rel="tag">Java</a>, <a href="http://bianbian.org/tag/spring" title="Spring" rel="tag">Spring</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/299.html" title="[原] solr 1.3 multicore使用指南 (2008-05-05)">[原] solr 1.3 multicore使用指南</a> (0)</li>
	<li><a href="http://bianbian.org/technology/88.html" title="[译]volatile关键字有什么用？ (2006-12-13)">[译]volatile关键字有什么用？</a> (3)</li>
	<li><a href="http://bianbian.org/technology/84.html" title="[原]Java正则表达式获取匹配结果 (2006-12-02)">[原]Java正则表达式获取匹配结果</a> (0)</li>
	<li><a href="http://bianbian.org/technology/74.html" title="[嗯]OSCache很不错啊 (2006-11-07)">[嗯]OSCache很不错啊</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/297.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] 关于正则表达式批量替换字符串解决方案答网友问</title>
		<link>http://bianbian.org/technology/javascript/296.html</link>
		<comments>http://bianbian.org/technology/javascript/296.html#comments</comments>
		<pubDate>Sun, 20 Apr 2008 07:43:00 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[正则表达式]]></category>

		<category><![CDATA[解决]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/javascript/296.html</guid>
		<description><![CDATA[发信人: Net (BBS上没有什么事情是bg不能解决的), 信区: WebDesign
标  题: Re: 如何使用正则分别替换？
发信站: 南京大学小百合站 (Sun Apr 20 15:21:23 2008)
不太可能一句话搞定，不过有相对而言的解决... ]]></description>
			<content:encoded><![CDATA[<p>发信人: Net (BBS上没有什么事情是bg不能解决的), 信区: WebDesign<br />
标  题: Re: 如何使用正则分别替换？<br />
发信站: 南京大学小百合站 (Sun Apr 20 15:21:23 2008)</p>
<p>不太可能一句话搞定，不过有相对而言的解决办法：<br />
1) 简单易懂</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">arrayReplace</span><span style="color: Olive;">(</span><span style="color: Blue;">str</span><span style="color: Gray;">, </span><span style="color: Blue;">from</span><span style="color: Gray;">, </span><span style="color: Blue;">to</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">for</span><span style="color: Olive;">(</span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">i</span><span style="color: Gray;">=</span><span style="color: Maroon;">0</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;"> &lt; </span><span style="color: Blue;">from</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">++</span><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">str</span><span style="color: Gray;"> = </span><span style="color: Blue;">str</span><span style="color: Gray;">.</span><span style="color: Blue;">replace</span><span style="color: Olive;">(</span><span style="color: Green;">new</span><span style="color: Gray;">&nbsp;</span><span style="color: Teal;">RegExp</span><span style="color: Olive;">(</span><span style="color: Blue;">from</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">g</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">, </span><span style="color: Blue;">to</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">])</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">str</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">from</span><span style="color: Gray;"> = </span><span style="color: Olive;">[</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">A</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">B</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">C</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: Blue;">to</span><span style="color: Gray;"> = </span><span style="color: Olive;">[</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">asdf</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">fdsa</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">......</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">str</span><span style="color: Gray;"> = </span><span style="color: Blue;">arrayReplace</span><span style="color: Olive;">(</span><span style="color: Blue;">str</span><span style="color: Gray;">, </span><span style="color: Blue;">from</span><span style="color: Gray;">, </span><span style="color: Blue;">to</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div>
<p>2) 勉强算一句话吧。。。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">str</span><span style="color: Gray;"> = </span><span style="color: Blue;">str</span><span style="color: Gray;">.</span><span style="color: Blue;">replace</span><span style="color: Olive;">(</span><span style="color: #8b0000;">/</span><span style="color: Red;">(A|B|C)</span><span style="color: #8b0000;">/g</span><span style="color: Gray;">, </span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Maroon;">0</span><span style="color: Gray;">, $</span><span style="color: Maroon;">1</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">A</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">asdf</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">B</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">fdsa</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">C</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">......</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">}[</span><span style="color: Gray;">$</span><span style="color: Maroon;">1</span><span style="color: Olive;">]</span></li>
<li><span style="color: Olive;">})</span><span style="color: Gray;">;</span></li></ol></div>
<p>【 在 superphoenix (格云朱雀) 的大作中提到: 】<br />
: 比如要将一个字符串中的A替换为asdf，B替换成fdsa，C替换成……<br />
: 能不能用一个正则话就替换成功？<br />
: 而不是写成str=str.replace(/A/g,&#8221;asdf&#8221;).replace(/B/g,&#8221;fdsa&#8221;)&#8230;.<br />
: 谢谢！</p>
<p>※ 来源:．南京大学小百合站 bbs.nju.edu.cn．[FROM: Net.nEt.neT.Orz]</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/javascript" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://bianbian.org/tag/%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f" title="正则表达式" rel="tag">正则表达式</a>, <a href="http://bianbian.org/tag/%e8%a7%a3%e5%86%b3" title="解决" rel="tag">解决</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/18.html" title="[原]AutoIt 3的GUI生成工具Koda (2006-09-06)">[原]AutoIt 3的GUI生成工具Koda</a> (1)</li>
	<li><a href="http://bianbian.org/technology/javascript/286.html" title="[原] 关于web访问小百合BBS的脚本问题 (2008-04-07)">[原] 关于web访问小百合BBS的脚本问题</a> (28)</li>
	<li><a href="http://bianbian.org/technology/javascript/263.html" title="[原] 整理了BBS的Javascript脚本，注意关键字 (2008-02-29)">[原] 整理了BBS的Javascript脚本，注意关键字</a> (2)</li>
	<li><a href="http://bianbian.org/technology/javascript/270.html" title="[原] 也许是prototype框架的bug (2008-03-08)">[原] 也许是prototype框架的bug</a> (0)</li>
	<li><a href="http://bianbian.org/technology/243.html" title="[原]qmail+vpopmail+maildrop+SpamAssassin遇到的错误及解决 (2008-01-05)">[原]qmail+vpopmail+maildrop+SpamAssassin遇到的错误及解决</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/javascript/296.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] php读取二进制流（C语言结构体struct数据文件）</title>
		<link>http://bianbian.org/technology/295.html</link>
		<comments>http://bianbian.org/technology/295.html#comments</comments>
		<pubDate>Sat, 19 Apr 2008 17:08:34 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[binary]]></category>

		<category><![CDATA[bug]]></category>

		<category><![CDATA[pack]]></category>

		<category><![CDATA[struct]]></category>

		<category><![CDATA[unpack]]></category>

		<category><![CDATA[二进制]]></category>

		<category><![CDATA[数据]]></category>

		<category><![CDATA[解决]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/295.html</guid>
		<description><![CDATA[尽管php是用C语言开发的，不过令我不解的是php没有提供对结构体struct的直接支持。
不过php提供了pack和unpack函数，用来进行二进制数据（binary data）和php内部数据的互转：
string&#160;pack ( string $fo... ]]></description>
			<content:encoded><![CDATA[<p>尽管php是用C语言开发的，不过令我不解的是php没有提供对结构体struct的直接支持。<br />
不过php提供了pack和unpack函数，用来进行二进制数据（binary data）和php内部数据的互转：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Blue;">string</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">pack</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Blue;">string</span><span style="color: Gray;"> </span><span style="color: #00008b;">$format</span><span style="color: Gray;"> </span><span style="color: Olive;">[</span><span style="color: Gray;">, </span><span style="color: Blue;">mixed</span><span style="color: Gray;"> </span><span style="color: #00008b;">$args</span><span style="color: Gray;"> </span><span style="color: Olive;">[</span><span style="color: Gray;">, </span><span style="color: Blue;">mixed</span><span style="color: Gray;"> $...</span><span style="color: Olive;">]]</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span></li>
<li><span style="color: #ffa500;">//Pack given arguments into binary string according to format. </span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Green;">array</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">unpack</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Blue;">string</span><span style="color: Gray;"> </span><span style="color: #00008b;">$format</span><span style="color: Gray;">, </span><span style="color: Blue;">string</span><span style="color: Gray;"> </span><span style="color: #00008b;">$data</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span></li>
<li><span style="color: #ffa500;">//Unpacks from a binary string into an array according to the given format.</span></li>
</ol></div>
<p>其中，$format跟perl里的pack格式类似，有如下一些（中文是我加的，有不准确的欢迎提出）：<br />
a NUL-padded string，即“\0”作为“空字符”的表示形式<br />
A SPACE-padded string，空格作为“空字符”的表示形式<br />
h Hex string, low nibble first，升序位顺序<br />
H Hex string, high nibble first，降序位顺序<br />
c signed char，有符号单字节<br />
C unsigned char，无符号单字节<br />
s signed short (always 16 bit, machine byte order)<br />
S unsigned short (always 16 bit, machine byte order)<br />
n unsigned short (always 16 bit, big endian byte order)<br />
v unsigned short (always 16 bit, little endian byte order)<br />
i signed integer (machine dependent size and byte order)<br />
I unsigned integer (machine dependent size and byte order)<br />
l signed long (always 32 bit, machine byte order)<br />
L unsigned long (always 32 bit, machine byte order)<br />
N unsigned long (always 32 bit, big endian byte order)<br />
V unsigned long (always 32 bit, little endian byte order)<br />
f float (machine dependent size and representation)<br />
d double (machine dependent size and representation)<br />
x NUL byte，实际使用的时候作为跳过多少字节用，很有用<br />
X Back up one byte，后退1字节<br />
@ NUL-fill to absolute position，实际使用的时候作为从开头跳到某字节用，很有用</p>
<p>实际使用发现：C里的“\0”（即字符串终止符）在php里并不是终止符，而是作为了字符串的一部分。因此，必须对“\0”进行特殊处理，才能进行struct和php内部数据的完美互转。比如 char name[10]; 如果实际数据是“62 69 61 6E 00 62 69 61 6E 00”，在C语言里第5个位置有终止符，name应该是“bian”；而用了unpack转换以后在php里的name却是“bian\0bian\0”。<br />
一开始我用了strpos函数找到“\0”的位置，然后进行substr截取：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #00008b;">$name</span><span style="color: Gray;"> = </span><span style="color: Blue;">substr</span><span style="color: Olive;">(</span><span style="color: #00008b;">$name</span><span style="color: Gray;">, </span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">strpos</span><span style="color: Olive;">(</span><span style="color: #00008b;">$name</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">\0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">))</span><span style="color: Gray;">;</span></li>
</ol></div>
<p>不过很Faint的事情发生了，不知道是strpos的bug还是substr的bug（其实测试一下就知道，懒得试），有些字符串没问题，有些字符串却只能得到空值（即$name == &#8221;）。很是郁闷，后来找了个strtok函数，这下没有问题了：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #00008b;">$name</span><span style="color: Gray;"> = </span><span style="color: Blue;">strtok</span><span style="color: Olive;">(</span><span style="color: #00008b;">$name</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">\0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
</ol></div>
<p>难为大家看了那么多，下面写个完整的php读取二进制数据流（C语言结构体struct数据）文件的示例代码：<br />
首先是C的struct定义示例，为了演示，我就写个简单点的，实际对照上面那个$format格式表应该没有问题：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span class="hl-types">struct</span><span style="color: Gray;"> </span><span style="color: Blue;">BIANBIAN</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span class="hl-types">char</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">name</span><span style="color: Olive;">[</span><span style="color: Maroon;">10</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span class="hl-types">char</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">pass</span><span style="color: Olive;">[</span><span style="color: Maroon;">33</span><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span class="hl-types">int</span><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">age</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span class="hl-types">unsigned</span><span style="color: Gray;">&nbsp;</span><span class="hl-types">char</span><span style="color: Gray;"> </span><span style="color: Blue;">flag</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span><span style="color: Gray;">;</span></li></ol></div>
<p>比如有个“bianbian.org”文件，内容就是上面的N个BIANBIAN结构体构成的。读取的php代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">//下面根据struct确定$format，注意int类型跟机器环境有关，我的32位Linux是4个长度</span></li>
<li><span style="color: #00008b;">$format</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">'</span><span style="color: Red;">a10name/a33pass/iage/Cflag</span><span style="color: #8b0000;">'</span><span style="color: Gray;">;</span></li>
<li><span style="color: #ffa500;">//确定一个struct占用多少长度字节，如果只是读取单个结构体这是不需要的</span></li>
<li><span style="color: #00008b;">$length</span><span style="color: Gray;"> = </span><span style="color: Maroon;">10</span><span style="color: Gray;"> + </span><span style="color: Maroon;">33</span><span style="color: Gray;"> + </span><span style="color: Maroon;">4</span><span style="color: Gray;"> + </span><span style="color: Maroon;">1</span><span style="color: Gray;">;</span></li>
<li><span style="color: #ffa500;">//也可以用fopen + fread + fclose，不过file_get_contents因为可以mmap，效率更高</span></li>
<li><span style="color: #00008b;">$data</span><span style="color: Gray;"> = </span><span style="color: Blue;">file_get_contents</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">bianbian.org</span><span style="color: #8b0000;">'</span><span style="color: Gray;">, </span><span style="color: #8b0000;">'</span><span style="color: Red;">r</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Green;">for</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: #00008b;">$i</span><span style="color: Gray;"> = </span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: #00008b;">$c</span><span style="color: Gray;"> = </span><span style="color: Blue;">strlen</span><span style="color: Olive;">(</span><span style="color: #00008b;">$data</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: #00008b;">$i</span><span style="color: Gray;"> &lt; </span><span style="color: #00008b;">$c</span><span style="color: Gray;">; </span><span style="color: #00008b;">$i</span><span style="color: Gray;"> += </span><span style="color: #00008b;">$length</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #00008b;">$bianbian</span><span style="color: Gray;"> = </span><span style="color: Blue;">unpack</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">@</span><span style="color: #00008b;">$i</span><span style="color: Red;">/</span><span style="color: #00008b;">$format</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #00008b;">$data</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: #ffa500;">//reference传递是php 5才支持的，如果用php4，得用其他办法</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Green;">foreach</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: #00008b;">$bianbian</span><span style="color: Gray;"> </span><span style="color: Green;">as</span><span style="color: Gray;"> &amp;</span><span style="color: #00008b;">$value</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">(</span><span style="color: Blue;">is_string</span><span style="color: Olive;">(</span><span style="color: #00008b;">$value</span><span style="color: Olive;">))</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">$value</span><span style="color: Gray;"> = </span><span style="color: Blue;">strtok</span><span style="color: Olive;">(</span><span style="color: #00008b;">$value</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">\0</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">print_r</span><span style="color: Olive;">(</span><span style="color: #00008b;">$bianbian</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: #ffa500;">//输出为array，即类似：</span></li>
<li><span style="color: Green;">Array</span></li>
<li><span style="color: Olive;">(</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">[</span><span style="color: Blue;">name</span><span style="color: Olive;">]</span><span style="color: Gray;"> =&gt; </span><span style="color: #8b0000;">'</span><span style="color: Red;">bianbian</span><span style="color: #8b0000;">'</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">[</span><span style="color: Blue;">pass</span><span style="color: Olive;">]</span><span style="color: Gray;"> =&gt; </span><span style="color: #8b0000;">'</span><span style="color: Red;">bianbian.org</span><span style="color: #8b0000;">'</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">[</span><span style="color: Blue;">age</span><span style="color: Olive;">]</span><span style="color: Gray;">&nbsp; =&gt; </span><span style="color: Maroon;">100</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">[</span><span style="color: Blue;">flag</span><span style="color: Olive;">]</span><span style="color: Gray;"> =&gt; </span><span style="color: Maroon;">0</span></li>
<li><span style="color: Olive;">)</span></li>
<li><span style="color: Gray;">...</span></li>
</ol></div>
<p>pack应该跟unpack相反。</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/binary" title="binary" rel="tag">binary</a>, <a href="http://bianbian.org/tag/bug" title="bug" rel="tag">bug</a>, <a href="http://bianbian.org/tag/pack" title="pack" rel="tag">pack</a>, <a href="http://bianbian.org/tag/php" title="php" rel="tag">php</a>, <a href="http://bianbian.org/tag/struct" title="struct" rel="tag">struct</a>, <a href="http://bianbian.org/tag/unpack" title="unpack" rel="tag">unpack</a>, <a href="http://bianbian.org/tag/%e4%ba%8c%e8%bf%9b%e5%88%b6" title="二进制" rel="tag">二进制</a>, <a href="http://bianbian.org/tag/%e6%95%b0%e6%8d%ae" title="数据" rel="tag">数据</a>, <a href="http://bianbian.org/tag/%e8%a7%a3%e5%86%b3" title="解决" rel="tag">解决</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/91.html" title="[原]涂鸦板oekakibbs和Shi-PainterPRO数据格式分析 (2006-12-19)">[原]涂鸦板oekakibbs和Shi-PainterPRO数据格式分析</a> (0)</li>
	<li><a href="http://bianbian.org/technology/142.html" title="[原]php用UTF-8编码总结 (2007-03-16)">[原]php用UTF-8编码总结</a> (0)</li>
	<li><a href="http://bianbian.org/technology/255.html" title="[晕] 发现gmail的问题 (2008-02-20)">[晕] 发现gmail的问题</a> (0)</li>
	<li><a href="http://bianbian.org/not-it/251.html" title="[哈] 饮水机断水之解决篇 (2008-02-05)">[哈] 饮水机断水之解决篇</a> (2)</li>
	<li><a href="http://bianbian.org/technology/javascript/284.html" title="[译] JavaScript (XMLHttpRequest) 读取二进制数据流 (2008-04-06)">[译] JavaScript (XMLHttpRequest) 读取二进制数据流</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/295.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] 强烈推荐一个纯java的FTP Client库：ftp4j</title>
		<link>http://bianbian.org/technology/294.html</link>
		<comments>http://bianbian.org/technology/294.html#comments</comments>
		<pubDate>Tue, 15 Apr 2008 03:08:02 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[FTP]]></category>

		<category><![CDATA[ftp4j]]></category>

		<category><![CDATA[FTPClient]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/294.html</guid>
		<description><![CDATA[ftp4j是个很年轻的开源项目，但是试用后发现很好很强大，如果你找一个纯java的FTP库，要支持socks4，socks4a，socks5，http代理，就是他了！
比apache的FTPClient（不支持代理）、半商业的edtFTPj（PRO支... ]]></description>
			<content:encoded><![CDATA[<p>ftp4j是个很年轻的开源项目，但是试用后发现很好很强大，如果你找一个纯java的FTP库，要支持socks4，socks4a，socks5，http代理，就是他了！<br />
比apache的FTPClient（不支持代理）、半商业的edtFTPj（PRO支持代理，但是要$，而且是系统变量级的代理，不能单个指定）等好用多了，而且是LGPL协议，源码质量很高。（不过如果你需要FTPS及SFTP，那ftp4j不支持）<br />
jar包只有50多k，地址在这里：<a href="http://www.sauronsoftware.it/projects/ftp4j/index.php" target=_blank>ftp4j</a><br />
使用代理的代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Green;">import</span><span style="color: Gray;"> </span><span style="color: Blue;">java</span><span style="color: Gray;">.</span><span style="color: Blue;">util</span><span style="color: Gray;">.</span><span style="color: Blue;">ArrayList</span><span style="color: Gray;">;</span></li>
<li><span style="color: Green;">import</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">it</span><span style="color: Gray;">.</span><span style="color: Blue;">sauronsoftware</span><span style="color: Gray;">.</span><span style="color: Blue;">ftp4j</span><span style="color: Gray;">.</span><span style="color: Blue;">FTPClient</span><span style="color: Gray;">;</span></li>
<li><span style="color: Green;">import</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">it</span><span style="color: Gray;">.</span><span style="color: Blue;">sauronsoftware</span><span style="color: Gray;">.</span><span style="color: Blue;">ftp4j</span><span style="color: Gray;">.</span><span style="color: Blue;">FTPFile</span><span style="color: Gray;">;</span></li>
<li><span style="color: Green;">import</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">it</span><span style="color: Gray;">.</span><span style="color: Blue;">sauronsoftware</span><span style="color: Gray;">.</span><span style="color: Blue;">ftp4j</span><span style="color: Gray;">.</span><span style="color: Blue;">connectors</span><span style="color: Gray;">.</span><span style="color: Blue;">SOCKS4Connector</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">......</span></li>
<li><span style="color: #ffa500;">//ftp4j使用socks4代理连接FTP示例，by </span><span style="color: Blue;">http://bianbian.org</span></li>
<li><span style="color: Blue;">FTPClient</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">ftp</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">FTPClient</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">SOCKS4Connector</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">socks4</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">SOCKS4Connector</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">127.0.0.1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Maroon;">1080</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">ftp</span><span style="color: Gray;">.</span><span style="color: Blue;">setConnector</span><span style="color: Olive;">(</span><span style="color: Blue;">socks4</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">ftp</span><span style="color: Gray;">.</span><span style="color: Blue;">connect</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">an.ip.or.host</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Maroon;">21</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">ftp</span><span style="color: Gray;">.</span><span style="color: Blue;">login</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">anonymous</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">bianbian@bianbian.org</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">ftp</span><span style="color: Gray;">.</span><span style="color: Blue;">setCharset</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">gbk</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: #ffa500;">//list files</span></li>
<li><span style="color: Blue;">FTPFile</span><span style="color: Olive;">[]</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">list</span><span style="color: Gray;"> = </span><span style="color: Blue;">ftp</span><span style="color: Gray;">.</span><span style="color: Blue;">list</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Green;">for</span><span style="color: Olive;">(</span><span style="color: Blue;">FTPFile</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">file</span><span style="color: Gray;"> : </span><span style="color: Blue;">list</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Blue;">System</span><span style="color: Gray;">.</span><span style="color: Blue;">out</span><span style="color: Gray;">.</span><span style="color: Blue;">println</span><span style="color: Olive;">(</span><span style="color: Blue;">file</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Olive;">}</span></li>
<li><span style="color: Blue;">ftp</span><span style="color: Gray;">.</span><span style="color: Blue;">disconnect</span><span style="color: Olive;">(</span><span style="color: Green;">true</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/ftp" title="FTP" rel="tag">FTP</a>, <a href="http://bianbian.org/tag/ftp4j" title="ftp4j" rel="tag">ftp4j</a>, <a href="http://bianbian.org/tag/ftpclient" title="FTPClient" rel="tag">FTPClient</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/311.html" title="[原] ftp4j的解析list的bug及解决 (2008-06-19)">[原] ftp4j的解析list的bug及解决</a> (3)</li>
	<li><a href="http://bianbian.org/technology/246.html" title="[原]关于Indy组件(Delphi)实现FTP上传断点续传的方法 (upload resume) (2008-01-15)">[原]关于Indy组件(Delphi)实现FTP上传断点续传的方法 (upload resume)</a> (1)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/294.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] php 5读取非UTF-8编码的文件或网页乱码的解决</title>
		<link>http://bianbian.org/technology/293.html</link>
		<comments>http://bianbian.org/technology/293.html#comments</comments>
		<pubDate>Wed, 09 Apr 2008 13:16:57 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[UTF-8]]></category>

		<category><![CDATA[乱码]]></category>

		<category><![CDATA[解决]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/293.html</guid>
		<description><![CDATA[php 5的流读取函数好像默认编码是UTF-8，以前在php 4里直接file_get_contents()读取gb2312编码的正常，到了5就乱码了。网上的解决办法说抓取后用iconv()转码。看后我就觉得不对劲：一个是不一定编译... ]]></description>
			<content:encoded><![CDATA[<p>php 5的流读取函数好像默认编码是UTF-8，以前在php 4里直接file_get_contents()读取gb2312编码的正常，到了5就乱码了。网上的解决办法说抓取后用iconv()转码。看后我就觉得不对劲：一个是不一定编译了iconv库，更大的问题是编码都跟流转换的时候有关（如果用了iconv实际上php转了两次码：流 -> UTF-8 -> GB2312）：这不是白忙乎了吗？</p>
<p>仔细看了下php的文档（不知道大家都是怎么写代码的，其实文档上很清楚啊），上面关于fopen()及file_get_contents()都提到了“默认是UTF-8，但是用户可以用stream_default_encoding()或者用户自定义上下文属性改变编码”（If unicode semantics are enabled, the default encoding of the read data is UTF-8. You can specify a different encoding by creating a custom context or by changing the default using stream_default_encoding().）。于是用stream_default_encoding(&#8217;gb2312&#8242;);测试：但是faint的是，这个函数不存在？！似乎php 6才支持。不过天无绝人之路，还有“用户自定义上下文属性”可以用。</p>
<p>经过更仔细的看文档，最后解决了这个问题：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">//设置流的编码格式，这是文件流(file)，如果是网络访问，file改成http</span></li>
<li><span style="color: #00008b;">$opts</span><span style="color: Gray;"> = </span><span style="color: Green;">array</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">file</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: Green;">array</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">encoding</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: #8b0000;">'</span><span style="color: Red;">gb2312</span><span style="color: #8b0000;">'</span><span style="color: Olive;">))</span><span style="color: Gray;">;</span></li>
<li><span style="color: #00008b;">$ctxt</span><span style="color: Gray;"> = </span><span style="color: Blue;">stream_context_create</span><span style="color: Olive;">(</span><span style="color: #00008b;">$opts</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Blue;">file_get_contents</span><span style="color: Olive;">(</span><span style="color: Gray;">文件名, </span><span style="color: Blue;">FILE_TEXT</span><span style="color: Gray;">, </span><span style="color: #00008b;">$ctxt</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
</ol></div>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/php" title="php" rel="tag">php</a>, <a href="http://bianbian.org/tag/utf-8" title="UTF-8" rel="tag">UTF-8</a>, <a href="http://bianbian.org/tag/%e4%b9%b1%e7%a0%81" title="乱码" rel="tag">乱码</a>, <a href="http://bianbian.org/tag/%e8%a7%a3%e5%86%b3" title="解决" rel="tag">解决</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/295.html" title="[原] php读取二进制流（C语言结构体struct数据文件） (2008-04-20)">[原] php读取二进制流（C语言结构体struct数据文件）</a> (4)</li>
	<li><a href="http://bianbian.org/technology/130.html" title="[原]C#里更改控件的显示Z顺序 (2007-03-01)">[原]C#里更改控件的显示Z顺序</a> (2)</li>
	<li><a href="http://bianbian.org/technology/144.html" title="[原]php处理base64编码和Unicode客户端交互的问题 (2007-03-19)">[原]php处理base64编码和Unicode客户端交互的问题</a> (2)</li>
	<li><a href="http://bianbian.org/technology/311.html" title="[原] ftp4j的解析list的bug及解决 (2008-06-19)">[原] ftp4j的解析list的bug及解决</a> (3)</li>
	<li><a href="http://bianbian.org/technology/javascript/202.html" title="[原]iframe跨域访问解决方案 (2007-08-24)">[原]iframe跨域访问解决方案</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/293.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] 根据struct生成基于JSON-C的json_object代码(auto generate function of C struct to JSON)</title>
		<link>http://bianbian.org/technology/292.html</link>
		<comments>http://bianbian.org/technology/292.html#comments</comments>
		<pubDate>Wed, 09 Apr 2008 03:13:37 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[C/C++]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[JSON]]></category>

		<category><![CDATA[struct]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/292.html</guid>
		<description><![CDATA[上次讨论了C的struct结构体与JSON交互，并提出了能否自动把struct转为JSON的问题。
今天我总算解决了这个问题，虽然中间也想过传参数给一个函数集中处理，不过都是比较麻烦。我写了一个脚本... ]]></description>
			<content:encoded><![CDATA[<p>上次讨论了C的struct结构体与JSON交互，并提出了能否自动把struct转为JSON的问题。<br />
今天我总算解决了这个问题，虽然中间也想过传参数给一个函数集中处理，不过都是比较麻烦。我写了一个脚本，自动生成把struct的成员插入json_object的函数，底下页面有演示：<a href="http://bianbian.org/document/c_struct_json.htm?bianbian.org">auto generate function of C struct to JSON</a>：<br />
<iframe src="http://bianbian.org/document/c_struct_json.htm?bianbian.org" width="100%" height="460" border=0></iframe></p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/json" title="JSON" rel="tag">JSON</a>, <a href="http://bianbian.org/tag/struct" title="struct" rel="tag">struct</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/javascript/223.html" title="[原]一种blog日历的JSON压缩输出算法 (2007-10-17)">[原]一种blog日历的JSON压缩输出算法</a> (1)</li>
	<li><a href="http://bianbian.org/technology/javascript/190.html" title="[原] C的struct和JSON交互 (2007-07-15)">[原] C的struct和JSON交互</a> (0)</li>
	<li><a href="http://bianbian.org/technology/295.html" title="[原] php读取二进制流（C语言结构体struct数据文件） (2008-04-20)">[原] php读取二进制流（C语言结构体struct数据文件）</a> (4)</li>
	<li><a href="http://bianbian.org/technology/90.html" title="[译]JSON的C语言实现: JSON-C - A JSON implementation in C (2006-12-17)">[译]JSON的C语言实现: JSON-C - A JSON implementation in C</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/292.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] 关于web访问小百合BBS的脚本问题</title>
		<link>http://bianbian.org/technology/javascript/286.html</link>
		<comments>http://bianbian.org/technology/javascript/286.html#comments</comments>
		<pubDate>Sun, 06 Apr 2008 17:28:38 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[BBS]]></category>

		<category><![CDATA[Firefox]]></category>

		<category><![CDATA[IE]]></category>

		<category><![CDATA[脚本]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/javascript/286.html</guid>
		<description><![CDATA[最近发现个别网友访问小百合BBS会出现如下提示：

见到此文字可能是由于浏览器禁用了活动脚本或者脚本有误
请启用脚本支持后刷新本页；若仍有问题，请点击这里提问

原理：使用Javascript... ]]></description>
			<content:encoded><![CDATA[<p>最近发现个别网友访问小百合BBS会出现如下提示：</p>
<blockquote><p>
见到此文字可能是由于浏览器禁用了活动脚本或者脚本有误<br />
请启用脚本支持后刷新本页；若仍有问题，请点击这里提问
</p></blockquote>
<p>原理：使用Javascript动态输出框架结构（好处是能缓存静态化网页，区别guest用户和登录用户）。因此，一旦这步出现错误，框架结构未建立成功，那么就会显示body里的提示内容。</p>
<p>原因：<br />
（1）浏览器版本不支持。目前小百合BBS支持IE5.5（不保证全部功能有效），完美支持IE6+、Firefox 2.0+、Opera 9+等。如果您的浏览器不在此列，并且测试正常，欢迎反馈。<br />
（2）浏览器脚本引擎未启用。您可以<a href="javascript:;" onclick="alert('脚本启用!')">点击这里测试</a>：如果能弹出“脚本启用”，那说明这项没有问题；否则，请修改设置如下：<br />
Firefox:<a href='http://bianbian.org/wp-content/uploads/2008/04/firefox_script_enable.JPG' title='firefox_script_enable.JPG' target=_img><img src='http://bianbian.org/wp-content/uploads/2008/04/firefox_script_enable.thumbnail.JPG' alt='firefox_script_enable.JPG' /></a> IE:<a href='http://bianbian.org/wp-content/uploads/2008/04/ie_script_enable.JPG' title='ie_script_enable.JPG' target=_img><img src='http://bianbian.org/wp-content/uploads/2008/04/ie_script_enable.thumbnail.JPG' alt='ie_script_enable.JPG' /></a><br />
（3）脚本有误。可能性不是很大，除非刚好碰到更新的脚本确实存在错误。基本上我都会测试以后才放上去。不过万一你怀疑是这个问题，可以telnet方式到sysop版看看，如果其他人都没问题那基本就只是您的问题了。<br />
（4）浏览器缓存内的脚本版本过旧。因为浏览器缓存脚本文件（这样不需要每次都下载，加快速度），如果服务器端已经更新了脚本文件，而您的浏览器缓存因为各种原因没有更新，可能也会导致这个问题。请清空浏览器缓存后刷新测试：<br />
Firefox:<a href='http://bianbian.org/wp-content/uploads/2008/04/firefox_del_temp.JPG' title='firefox_del_temp.JPG' target=_img><img src='http://bianbian.org/wp-content/uploads/2008/04/firefox_del_temp.thumbnail.JPG' alt='firefox_del_temp.JPG' /></a> IE:<a href='http://bianbian.org/wp-content/uploads/2008/04/ie_del_temp.JPG' title='ie_del_temp.JPG' target=_img><img src='http://bianbian.org/wp-content/uploads/2008/04/ie_del_temp.thumbnail.JPG' alt='ie_del_temp.JPG' /></a><br />
（5）校内用户访问BBS请关闭代理服务器。<br />
（6）浏览器或系统部分DLL（动态链接库）功能因为病毒或木马的原因失效（Windows系统），请<a href="http://bianbian.org/wp-content/uploads/2008/04/fixie.bat">点此下载修复程序</a>，保存后运行，然后重新打开浏览器测试。</p>
<p>如果还有问题，请留言将您的操作系统、浏览器（基本是IE出问题）及版本、杀毒软件等告知。另外推荐使用Firefox:<script>google_ad_client="pub-2964170835679337";google_ad_output="textlink";google_ad_format="ref_text";google_cpa_choice="CAAQqcu1_wEaCMVXofsEbjfHKOm84YcBMAA";WG()</script></p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/bbs" title="BBS" rel="tag">BBS</a>, <a href="http://bianbian.org/tag/firefox" title="Firefox" rel="tag">Firefox</a>, <a href="http://bianbian.org/tag/ie" title="IE" rel="tag">IE</a>, <a href="http://bianbian.org/tag/javascript" title="JavaScript" rel="tag">JavaScript</a>, <a href="http://bianbian.org/tag/%e8%84%9a%e6%9c%ac" title="脚本" rel="tag">脚本</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/javascript/26.html" title="[原]Create Tree menu from HHC file automatically (HHC转为树形菜单) (2006-09-08)">[原]Create Tree menu from HHC file automatically (HHC转为树形菜单)</a> (1)</li>
	<li><a href="http://bianbian.org/technology/javascript/275.html" title="[原] IE模拟鼠标右键双击事件 (2008-03-25)">[原] IE模拟鼠标右键双击事件</a> (1)</li>
	<li><a href="http://bianbian.org/technology/javascript/263.html" title="[原] 整理了BBS的Javascript脚本，注意关键字 (2008-02-29)">[原] 整理了BBS的Javascript脚本，注意关键字</a> (2)</li>
	<li><a href="http://bianbian.org/technology/javascript/45.html" title="[原] IE在UTF-8下解析JavaScript的bug (2006-10-20)">[原] IE在UTF-8下解析JavaScript的bug</a> (0)</li>
	<li><a href="http://bianbian.org/technology/javascript/296.html" title="[原] 关于正则表达式批量替换字符串解决方案答网友问 (2008-04-20)">[原] 关于正则表达式批量替换字符串解决方案答网友问</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/javascript/286.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[原] BBS日志和点击率的优化方向及静态化</title>
		<link>http://bianbian.org/technology/285.html</link>
		<comments>http://bianbian.org/technology/285.html#comments</comments>
		<pubDate>Sun, 06 Apr 2008 08:01:42 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<category><![CDATA[BBS]]></category>

		<category><![CDATA[memcached]]></category>

		<category><![CDATA[优化]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/285.html</guid>
		<description><![CDATA[尤其是点击率，是网站静态化最麻烦的地方之一：每个用户的每次点击都会改写.DIR文件，也是负担
而且除了看一眼没有其他用处，而且没有办法保证不作弊（blog点击率作弊尤其多）
我想了个... ]]></description>
			<content:encoded><![CDATA[<p>尤其是点击率，是网站静态化最麻烦的地方之一：每个用户的每次点击都会改写.DIR文件，也是负担<br />
而且除了看一眼没有其他用处，而且没有办法保证不作弊（blog点击率作弊尤其多）</p>
<p>我想了个办法：tmpfs+数据库（比如MySQL）<br />
1）把所有点击率以日志的形式记录到tmpfs（ramdisk）某文件log.tmp（点一次存一行）<br />
   格式：bbs BoardName FileName UserId IP<br />
            blog BlogUserId FileName UserId IP<br />
            an Path UserId IP<br />
    因为是内存操作，非常快<br />
2）10分钟crontab把log.tmp改名log.10，然后另外启动程序分析log.10<br />
    去除UserId和IP相同的重复记录（10分钟内同ip同id重复点击只算一次）<br />
   把结果一次insert到MySQL，因为是multi insert，即使log很大，其实是非常快的<br />
3）进入数据库以后就好办了，可以出各种统计：<br />
   1小时内热门，12小时内热门，24小时内热门，本周热门。。。。。。<br />
   这块统计（数据挖掘）其实是目前基于文件系统的BBS最缺的地方，自己写会很辛苦<br />
   这块结果输出可以用memcached优化，10分钟从数据库跑一次SQL即可</p>
<p>这样.DIR就不需要改变，而且可以把.DIR部分cache到内存里，结合libevent，有数据改写reload一次</p>
<p>唯一的缺点是显示的时候要从数据库内取，必须memcached，而且10分钟才会更新一次<br />
不过比起带来的好处来看，是微不足道的</p>
<p>针对其他日志的数据挖掘：除了能出各种统计图表外，对于遍历试密码的可以直接从iptables过滤<br />
我准备等我忙完毕业的事情好好实现一下。</p>
<p>&copy;2008 <a href="http://bianbian.org">bianbian coding life</a>. All Rights Reserved.</p>.
	标签: <a href="http://bianbian.org/tag/bbs" title="BBS" rel="tag">BBS</a>, <a href="http://bianbian.org/tag/memcached" title="memcached" rel="tag">memcached</a>, <a href="http://bianbian.org/tag/%e4%bc%98%e5%8c%96" title="优化" rel="tag">优化</a><br /><br/>遵守创作共用协议，转载请链接形式注明来自<a href="http://bianbian.org" target=_blank>http://bianbian.org</a> 做人要厚道

	<h4>相关日志</h4>
	<ul class='st-related-posts'>
	<li><a href="http://bianbian.org/technology/javascript/263.html" title="[原] 整理了BBS的Javascript脚本，注意关键字 (2008-02-29)">[原] 整理了BBS的Javascript脚本，注意关键字</a> (2)</li>
	<li><a href="http://bianbian.org/technology/javascript/286.html" title="[原] 关于web访问小百合BBS的脚本问题 (2008-04-07)">[原] 关于web访问小百合BBS的脚本问题</a> (28)</li>
	<li><a href="http://bianbian.org/technology/283.html" title="[原] 未来分布式BBS的可能实现架构 (2008-04-04)">[原] 未来分布式BBS的可能实现架构</a> (0)</li>
	<li><a href="http://bianbian.org/technology/javascript/300.html" title="[原] 给LilyBBS新增源代码语法高亮功能 (2008-05-06)">[原] 给LilyBBS新增源代码语法高亮功能</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://bianbian.org/technology/285.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>[译] JavaScript (XMLHttpRequest) 读取二进制数据流</title>
		<link>http://bianbian.org/technology/javascript/284.html</link>
		<comments>http://bianbian.org/technology/javascript/284.html#comments</comments>
		<pubDate>Sun, 06 Apr 2008 05:36:30 +0000</pubDate>
		<dc:creator>bianbian</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[Firefox]]></category>

		<category><![CDATA[XMLHttpRequest]]></category>

		<category><![CDATA[二进制]]></category>

		<category><![CDATA[数据]]></category>

		<guid isPermaLink="false">http://bianbian.org/technology/javascript/284.html</guid>
		<description><![CDATA[译者注：原来想用JS直接处理C丢过来的struct数据，具体可以查看：[原] C的struct和JSON交互。
经过千辛万苦的查找，找到了这篇文章（作者应该比我更辛苦）：Downloading Binary Streams with Javascript XMLH... ]]></description>
			<content:encoded><![CDATA[<p>译者注：原来想用JS直接处理C丢过来的struct数据，具体可以查看：<a href="http://bianbian.org/technology/javascript/190.html" target=_blank>[原] C的struct和JSON交互</a>。<br />
经过千辛万苦的查找，找到了这篇文章（作者应该比我更辛苦）：<a href="http://mgran.blogspot.com/2006/08/downloading-binary-streams-with.html" target=_blank>Downloading Binary Streams with Javascript XMLHttpRequest</a><br />
把关键点翻译如下（不过我还没有测试）：<br />
利用XMLHttpRequest的overrideMimeType方法设置charset为x-user-defined。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">//fetches BINARY FILES synchronously using XMLHttpRequest</span></li>
<li><span style="color: Blue;">load_url</span><span style="color: Gray;"> = </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">url</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">netscape</span><span style="color: Gray;">.</span><span style="color: Blue;">security</span><span style="color: Gray;">.</span><span style="color: Blue;">PrivilegeManager</span><span style="color: Gray;">.</span><span style="color: Blue;">enablePrivilege</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">UniversalBrowserRead</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">req</span><span style="color: Gray;"> = </span><span style="color: Green;">new</span><span style="color: Gray;"> </span><span style="color: Blue;">XMLHttpRequest</span><span style="color: Olive;">()</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">req</span><span style="color: Gray;">.</span><span style="color: Blue;">open</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">GET</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: Blue;">url</span><span style="color: Gray;">,</span><span style="color: Green;">false</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #ffa500;">//XHR binary charset opt by Marcus Granado 2006 [</span><span style="color: Blue;">http://mgran.blogspot.com</span><span style="color: #ffa500;">] </span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">req</span><span style="color: Gray;">.</span><span style="color: Blue;">overrideMimeType</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">text/plain; charset=x-user-defined</span><span style="color: #8b0000;">'</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Blue;">req</span><span style="color: Gray;">.</span><span style="color: Blue;">send</span><span style="color: Olive;">(</span><span style="color: Green;">null</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color