ZealOS/docs/System/DolDoc/DocBin.html
2021-07-03 00:07:57 -04:00

199 lines
18 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.05">
<style type="text/css">
body {background-color:#000000;}
.cF0{color:#ffffff;background-color:#000000;}
.cF1{color:#3465a4;background-color:#000000;}
.cF2{color:#4e9a06;background-color:#000000;}
.cF3{color:#06989a;background-color:#000000;}
.cF4{color:#a24444;background-color:#000000;}
.cF5{color:#75507b;background-color:#000000;}
.cF6{color:#ce982f;background-color:#000000;}
.cF7{color:#bcc0b9;background-color:#000000;}
.cF8{color:#555753;background-color:#000000;}
.cF9{color:#729fcf;background-color:#000000;}
.cFA{color:#82bc49;background-color:#000000;}
.cFB{color:#34e2e2;background-color:#000000;}
.cFC{color:#ac3535;background-color:#000000;}
.cFD{color:#ad7fa8;background-color:#000000;}
.cFE{color:#fce94f;background-color:#000000;}
.cFF{color:#000000;background-color:#000000;}
</style>
</head>
<body>
<pre style="font-family:courier;font-size:10pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>&quot;DolDoc/Bin&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF9>CDocBin</span><span class=cF0> *</span><span class=cF5>DocBinFindNum</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *haystack_doc, </span><span class=cF9>I64</span><span class=cF0> needle_num)
<a name="l4"></a>{
<a name="l5"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *b = haystack_doc-&gt;bin_head.next;
<a name="l6"></a>
<a name="l7"></a> </span><span class=cF1>while</span><span class=cF0> (b != &amp;haystack_doc-&gt;bin_head)
<a name="l8"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l9"></a> </span><span class=cF1>if</span><span class=cF0> (b-&gt;num == needle_num)
<a name="l10"></a> </span><span class=cF1>return</span><span class=cF0> b;
<a name="l11"></a> b = b-&gt;next;
<a name="l12"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l13"></a>
<a name="l14"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l15"></a>}
<a name="l16"></a>
<a name="l17"></a></span><span class=cF9>CDocBin</span><span class=cF0> *</span><span class=cF5>DocBinFindTag</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *haystack_doc, </span><span class=cF1>U8</span><span class=cF0> *needle_tag)
<a name="l18"></a>{
<a name="l19"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *b;
<a name="l20"></a>
<a name="l21"></a> </span><span class=cF1>if</span><span class=cF0> (needle_tag)
<a name="l22"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l23"></a> b = haystack_doc-&gt;bin_head.next;
<a name="l24"></a> </span><span class=cF1>while</span><span class=cF0> (b != &amp;haystack_doc-&gt;bin_head)
<a name="l25"></a> {
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (b-&gt;tag &amp;&amp; !</span><span class=cF5>StrCompare</span><span class=cF7>(</span><span class=cF0>b-&gt;tag, needle_tag</span><span class=cF7>)</span><span class=cF0>)
<a name="l27"></a> </span><span class=cF1>return</span><span class=cF0> b;
<a name="l28"></a> b = b-&gt;next;
<a name="l29"></a> }
<a name="l30"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l31"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l32"></a>}
<a name="l33"></a>
<a name="l34"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DocBinsValidate</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc)
<a name="l35"></a>{
<a name="l36"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock = </span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l37"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *b, *b1;
<a name="l38"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e, *doc_e2;
<a name="l39"></a> </span><span class=cF9>I64</span><span class=cF0> renum_num = </span><span class=cFE>0</span><span class=cF0>;
<a name="l40"></a>
<a name="l41"></a> b = doc-&gt;bin_head.next;
<a name="l42"></a> </span><span class=cF1>while</span><span class=cF0> (b != &amp;doc-&gt;bin_head)
<a name="l43"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l44"></a> b-&gt;use_count = </span><span class=cFE>0</span><span class=cF0>;
<a name="l45"></a> b-&gt;tmp_use_count= </span><span class=cFE>0</span><span class=cF0>;
<a name="l46"></a> b-&gt;renum_num = -</span><span class=cFE>1</span><span class=cF0>;
<a name="l47"></a> </span><span class=cF5>Free</span><span class=cF0>(b-&gt;tag);
<a name="l48"></a> b-&gt;tag = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l49"></a> b = b-&gt;next;
<a name="l50"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l51"></a> doc_e = doc-&gt;head.next;
<a name="l52"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l53"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l54"></a> doc_e2 = doc_e-&gt;next;
<a name="l55"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;de_flags &amp; </span><span class=cF3>DOCEF_HAS_BIN</span><span class=cF0>)
<a name="l56"></a> {
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (b = doc_e-&gt;bin_data = </span><span class=cF5>DocBinFindNum</span><span class=cF7>(</span><span class=cF0>doc, doc_e-&gt;bin_num</span><span class=cF7>)</span><span class=cF0>)
<a name="l58"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l59"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;de_flags &amp; </span><span class=cF3>DOCEF_BIN_PTR_LINK</span><span class=cF0>)
<a name="l60"></a> b-&gt;tmp_use_count = </span><span class=cF3>I32_MAX</span><span class=cF0>;
<a name="l61"></a> </span><span class=cF1>if</span><span class=cF0> (!b-&gt;use_count++)
<a name="l62"></a> b-&gt;renum_num = ++renum_num;
<a name="l63"></a> doc_e-&gt;bin_num = b-&gt;renum_num;
<a name="l64"></a> </span><span class=cF1>if</span><span class=cF0> (!b-&gt;tag &amp;&amp; doc_e-&gt;de_flags &amp; </span><span class=cF3>DOCEF_TAG</span><span class=cF0> &amp;&amp; doc_e-&gt;tag &amp;&amp; *doc_e-&gt;tag)
<a name="l65"></a> b-&gt;tag = </span><span class=cF5>StrNew</span><span class=cF0>(doc_e-&gt;tag, doc-&gt;mem_task);
<a name="l66"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l67"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l68"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l69"></a> </span><span class=cF5>RawPrint</span><span class=cF0>(</span><span class=cFE>3000</span><span class=cF0>, </span><span class=cF6>&quot;Bin Not Found&quot;</span><span class=cF0>);
<a name="l70"></a> doc_e-&gt;type = doc_e-&gt;de_flags = </span><span class=cFE>0</span><span class=cF0>;
<a name="l71"></a> doc_e-&gt;type_u8 = </span><span class=cF3>DOCT_ERROR</span><span class=cF0>;
<a name="l72"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l73"></a> }
<a name="l74"></a> doc_e = doc_e2;
<a name="l75"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l76"></a>
<a name="l77"></a> b = doc-&gt;bin_head.next;
<a name="l78"></a> doc-&gt;cur_bin_num = </span><span class=cFE>1</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF1>while</span><span class=cF0> (b != &amp;doc-&gt;bin_head)
<a name="l80"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l81"></a> b1 = b-&gt;next;
<a name="l82"></a> </span><span class=cF1>if</span><span class=cF0> (!b-&gt;use_count)
<a name="l83"></a> {
<a name="l84"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(b);
<a name="l85"></a> </span><span class=cF5>Free</span><span class=cF0>(b-&gt;data);
<a name="l86"></a> </span><span class=cF5>Free</span><span class=cF0>(b);
<a name="l87"></a> }
<a name="l88"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l89"></a> {
<a name="l90"></a> b-&gt;num = b-&gt;renum_num;
<a name="l91"></a> </span><span class=cF1>if</span><span class=cF0> (b-&gt;num &gt;= doc-&gt;cur_bin_num)
<a name="l92"></a> doc-&gt;cur_bin_num = b-&gt;num + </span><span class=cFE>1</span><span class=cF0>;
<a name="l93"></a> }
<a name="l94"></a> b = b1;
<a name="l95"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
<a name="l97"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l98"></a>}
<a name="l99"></a>
<a name="l100"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>DocBinDel</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc, </span><span class=cF9>CDocBin</span><span class=cF0> *b)
<a name="l101"></a>{
<a name="l102"></a> </span><span class=cF1>if</span><span class=cF0> (doc &amp;&amp; b &amp;&amp; b-&gt;use_count)
<a name="l103"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l104"></a> b-&gt;use_count--;
<a name="l105"></a> </span><span class=cF1>if</span><span class=cF0> (!b-&gt;use_count)
<a name="l106"></a> {
<a name="l107"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(b);
<a name="l108"></a> </span><span class=cF5>Free</span><span class=cF0>(b-&gt;tag);
<a name="l109"></a> </span><span class=cF5>Free</span><span class=cF0>(b-&gt;data);
<a name="l110"></a> </span><span class=cF5>Free</span><span class=cF0>(b);
<a name="l111"></a> }
<a name="l112"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l113"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l114"></a> </span><span class=cF5>RawPrint</span><span class=cF0>(</span><span class=cFE>3000</span><span class=cF0>, </span><span class=cF6>&quot;DocBinDel&quot;</span><span class=cF0>);
<a name="l115"></a>}
<a name="l116"></a>
<a name="l117"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DocBinPtrReset</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc, </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e)
<a name="l118"></a>{
<a name="l119"></a> </span><span class=cF1>U8</span><span class=cF0> *st, *st2;
<a name="l120"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc2;
<a name="l121"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *tmpb, *tmpb2;
<a name="l122"></a> </span><span class=cF9>I64</span><span class=cF0> i, bin_num = </span><span class=cFE>0</span><span class=cF0>;
<a name="l123"></a>
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;de_flags &amp; </span><span class=cF3>DOCEF_HAS_BIN</span><span class=cF0> &amp;&amp; doc_e-&gt;bin_ptr_link &amp;&amp; </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>doc_e-&gt;bin_ptr_link</span><span class=cF7>)</span><span class=cF0>)
<a name="l125"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l126"></a> bin_num = doc_e-&gt;bin_num;
<a name="l127"></a> st = </span><span class=cF5>StrNew</span><span class=cF0>(doc_e-&gt;bin_ptr_link);
<a name="l128"></a> st2 = </span><span class=cF5>StrNew</span><span class=cF0>(st);
<a name="l129"></a> </span><span class=cF5>StrLastRemove</span><span class=cF0>(st, </span><span class=cF6>&quot;,&quot;</span><span class=cF0>, st2);
<a name="l130"></a> i = </span><span class=cF5>Str2I64</span><span class=cF0>(st2);
<a name="l131"></a> </span><span class=cF1>if</span><span class=cF0> (i &gt; </span><span class=cFE>0</span><span class=cF0> || *st2)
<a name="l132"></a> {
<a name="l133"></a> doc2 = </span><span class=cF5>DocRead</span><span class=cF0>(st);
<a name="l134"></a> </span><span class=cF1>if</span><span class=cF0> (i &gt; </span><span class=cFE>0</span><span class=cF0> &amp;&amp; </span><span class=cF7>(</span><span class=cF0>tmpb2 = </span><span class=cF5>DocBinFindNum</span><span class=cF0>(doc2, i)</span><span class=cF7>)</span><span class=cF0> || i == </span><span class=cFE>0</span><span class=cF0> &amp;&amp; </span><span class=cF7>(</span><span class=cF0>tmpb2 = </span><span class=cF5>DocBinFindTag</span><span class=cF0>(doc2, st2)</span><span class=cF7>)</span><span class=cF0>)
<a name="l135"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l136"></a> i = </span><span class=cFE>1</span><span class=cF0>;
<a name="l137"></a> </span><span class=cF1>if</span><span class=cF0> (bin_num &gt; </span><span class=cFE>0</span><span class=cF0>)
<a name="l138"></a> {
<a name="l139"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb = </span><span class=cF5>DocBinFindNum</span><span class=cF7>(</span><span class=cF0>doc, bin_num</span><span class=cF7>)</span><span class=cF0>)
<a name="l140"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l141"></a> i = tmpb-&gt;use_count;
<a name="l142"></a> </span><span class=cF5>DocBinDel</span><span class=cF0>(doc, tmpb);
<a name="l143"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l144"></a> }
<a name="l145"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l146"></a> bin_num = doc-&gt;cur_bin_num++;
<a name="l147"></a>
<a name="l148"></a> tmpb = </span><span class=cF5>MAllocIdent</span><span class=cF0>(tmpb2, doc-&gt;mem_task);
<a name="l149"></a> tmpb-&gt;use_count = i;
<a name="l150"></a> tmpb-&gt;data = </span><span class=cF5>MAllocIdent</span><span class=cF0>(tmpb2-&gt;data, doc-&gt;mem_task);
<a name="l151"></a> tmpb-&gt;num = bin_num;
<a name="l152"></a> doc_e-&gt;bin_data = tmpb;
<a name="l153"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;de_flags &amp; </span><span class=cF3>DOCEF_TAG</span><span class=cF0> &amp;&amp; doc_e-&gt;tag &amp;&amp; *doc_e-&gt;tag)
<a name="l154"></a> tmpb-&gt;tag = </span><span class=cF5>StrNew</span><span class=cF0>(doc_e-&gt;tag, doc-&gt;mem_task);
<a name="l155"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l156"></a> tmpb-&gt;tag = </span><span class=cF3>NULL</span><span class=cF0>;
<a name="l157"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpb, doc-&gt;bin_head.last);
<a name="l158"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l159"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l160"></a> bin_num = </span><span class=cFE>0</span><span class=cF0>;
<a name="l161"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc2);
<a name="l162"></a> }
<a name="l163"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l164"></a> bin_num = </span><span class=cFE>0</span><span class=cF0>;
<a name="l165"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
<a name="l166"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l167"></a> doc_e-&gt;bin_num = bin_num;
<a name="l168"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l169"></a> </span><span class=cF1>return</span><span class=cF0> bin_num;
<a name="l170"></a>}
</span></pre></body>
</html>