PHP Variable Zend Hash Calculater

Published on 2006 - 08 - 15
    <div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
            <span style="COLOR: #008000">/*</span>
            <span style="COLOR: #008000">
                    <br />*<br />* PHP Variable Zend Hash Calculater<br />* Author: wofeiwo<br />*<br /></span>
            <span style="COLOR: #008000">*/</span>
            <span style="COLOR: #000000">
                    <br />
                    <br />
            </span>
            <span style="COLOR: #008000">#</span>
            <span style="COLOR: #008000">include &lt;stdio.h&gt;</span>
            <span style="COLOR: #008000">
                    <br />#</span>
            <span style="COLOR: #008000">include &lt;stdlib.h&gt;</span>
            <span style="COLOR: #008000">
                    <br />#</span>
            <span style="COLOR: #008000">include &lt;string.h&gt;</span>
            <span style="COLOR: #008000">
                    <br />
            </span>
            <span style="COLOR: #000000">
                    <br />unsigned long zend_inline_hash_func(char </span>
            <span style="COLOR: #000000">*</span>
            <span style="COLOR: #000000">arKey</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> int nKeyLength</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> int nVersion)<br />{<br />    unsigned long h </span>
            <span style="COLOR: #000000">=</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">5381</span>
            <span style="COLOR: #000000">;<br />    char </span>
            <span style="COLOR: #000000">*</span>
            <span style="COLOR: #000000">arEnd </span>
            <span style="COLOR: #000000">=</span>
            <span style="COLOR: #000000"> arKey </span>
            <span style="COLOR: #000000">+</span>
            <span style="COLOR: #000000"> nKeyLength;<br /> <br />    </span>
            <span style="COLOR: #0000ff">while</span>
            <span style="COLOR: #000000"> (arKey </span>
            <span style="COLOR: #000000">&lt;</span>
            <span style="COLOR: #000000"> arEnd) {<br />        h </span>
            <span style="COLOR: #000000">+=</span>
            <span style="COLOR: #000000"> (h </span>
            <span style="COLOR: #000000">&lt;&lt;</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">5</span>
            <span style="COLOR: #000000">);<br />        </span>
            <span style="COLOR: #0000ff">switch</span>
            <span style="COLOR: #000000">(nVersion){<br />        </span>
            <span style="COLOR: #0000ff">case</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">4</span>
            <span style="COLOR: #000000">:</span>
            <span style="COLOR: #000000"> h </span>
            <span style="COLOR: #000000">^=</span>
            <span style="COLOR: #000000"> (unsigned long) </span>
            <span style="COLOR: #000000">*</span>
            <span style="COLOR: #000000">arKey</span>
            <span style="COLOR: #000000">++</span>
            <span style="COLOR: #000000">;</span>
            <span style="COLOR: #0000ff">break</span>
            <span style="COLOR: #000000">;<br />        </span>
            <span style="COLOR: #0000ff">case</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">5</span>
            <span style="COLOR: #000000">:</span>
            <span style="COLOR: #000000"> h </span>
            <span style="COLOR: #000000">+=</span>
            <span style="COLOR: #000000"> (unsigned long) </span>
            <span style="COLOR: #000000">*</span>
            <span style="COLOR: #000000">arKey</span>
            <span style="COLOR: #000000">++</span>
            <span style="COLOR: #000000">;</span>
            <span style="COLOR: #0000ff">break</span>
            <span style="COLOR: #000000">;<br />        }<br />    }<br />    </span>
            <span style="COLOR: #0000ff">return</span>
            <span style="COLOR: #000000"> h;<br />}<br /><br />int main(int argc</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> char </span>
            <span style="COLOR: #000000">*</span>
            <span style="COLOR: #000000">argv[])<br />{<br />    unsigned long hash4;<br />    unsigned long hash5</span>
            <span style="COLOR: #000000">;<br /><br />    </span>
            <span style="COLOR: #008080">printf</span>
            <span style="COLOR: #000000">(</span>
            <span style="COLOR: #000000">"</span>
            <span style="COLOR: #000000">PHP Variable Zend Hash Calculater\r\nAuthor: wofeiwo\r\n\r\n</span>
            <span style="COLOR: #000000">"</span>
            <span style="COLOR: #000000">);<br />    </span>
            <span style="COLOR: #0000ff">if</span>
            <span style="COLOR: #000000">(argc </span>
            <span style="COLOR: #000000">!=</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">2</span>
            <span style="COLOR: #000000">) <br />    {<br />        </span>
            <span style="COLOR: #008080">printf</span>
            <span style="COLOR: #000000">(</span>
            <span style="COLOR: #000000">"</span>
            <span style="COLOR: #000000">Usage: %s &lt;string&gt;\r\n</span>
            <span style="COLOR: #000000">"</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> argv[</span>
            <span style="COLOR: #000000">0</span>
            <span style="COLOR: #000000">]);<br />        </span>
            <span style="COLOR: #0000ff">exit</span>
            <span style="COLOR: #000000">(</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">);<br />    }<br /><br />    hash4 </span>
            <span style="COLOR: #000000">=</span>
            <span style="COLOR: #000000"> zend_inline_hash_func(argv[</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">]</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #008080">strlen</span>
            <span style="COLOR: #000000">(argv[</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">])</span>
            <span style="COLOR: #000000">+</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">4</span>
            <span style="COLOR: #000000">);<br />    hash5 </span>
            <span style="COLOR: #000000">=</span>
            <span style="COLOR: #000000"> zend_inline_hash_func(argv[</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">]</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #008080">strlen</span>
            <span style="COLOR: #000000">(argv[</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">])</span>
            <span style="COLOR: #000000">+</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">5</span>
            <span style="COLOR: #000000">);<br />    </span>
            <span style="COLOR: #008080">printf</span>
            <span style="COLOR: #000000">(</span>
            <span style="COLOR: #000000">"</span>
            <span style="COLOR: #000000">String: %s\r\nPHP4 HASH: %ld\r\nPHP5 HASH: %ld\r\n</span>
            <span style="COLOR: #000000">"</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> argv[</span>
            <span style="COLOR: #000000">1</span>
            <span style="COLOR: #000000">]</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> hash4</span>
            <span style="COLOR: #000000">,</span>
            <span style="COLOR: #000000"> hash5);<br />    </span>
            <span style="COLOR: #0000ff">return</span>
            <span style="COLOR: #000000"> </span>
            <span style="COLOR: #000000">0</span>
            <span style="COLOR: #000000">;<br />}</span>
    </div>
Comments
Write a Comment