174 lines
14 KiB
HTML
Executable File
174 lines
14 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="generator" content="TempleOS V5.03">
|
|
<meta name="viewport" content="width=device-width">
|
|
<link rel="stylesheet" href="/style/templeos.css">
|
|
<script src="/script/templeos.js"></script>
|
|
<style type="text/css">
|
|
.cF0{color:#000000;background-color:#ffffff;}
|
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
|
.cF8{color:#555555;background-color:#ffffff;}
|
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre id="content">
|
|
<a name="l1"></a><span class=cF0>#</span><span class=cF1>help_index</span><span class=cF0> </span><span class=cF6>"DolDoc/Bin"</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->bin_head.next;
|
|
<a name="l6"></a> </span><span class=cF1>while</span><span class=cF0> (b!=&haystack_doc->bin_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l7"></a> </span><span class=cF1>if</span><span class=cF0> (b->num==needle_num)
|
|
<a name="l8"></a> </span><span class=cF1>return</span><span class=cF0> b;
|
|
<a name="l9"></a> b=b->next;
|
|
<a name="l10"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l11"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l12"></a>}
|
|
<a name="l13"></a>
|
|
<a name="l14"></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="l15"></a>{
|
|
<a name="l16"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *b;
|
|
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (needle_tag) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l18"></a> b=haystack_doc->bin_head.next;
|
|
<a name="l19"></a> </span><span class=cF1>while</span><span class=cF0> (b!=&haystack_doc->bin_head) {
|
|
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (b->tag && !</span><span class=cF5>StrCmp</span><span class=cF7>(</span><span class=cF0>b->tag,needle_tag</span><span class=cF7>)</span><span class=cF0>)
|
|
<a name="l21"></a> </span><span class=cF1>return</span><span class=cF0> b;
|
|
<a name="l22"></a> b=b->next;
|
|
<a name="l23"></a> }
|
|
<a name="l24"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l25"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l26"></a>}
|
|
<a name="l27"></a>
|
|
<a name="l28"></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="l29"></a>{
|
|
<a name="l30"></a> </span><span class=cF1>Bool</span><span class=cF0> unlock=</span><span class=cF5>DocLock</span><span class=cF0>(doc);
|
|
<a name="l31"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *b,*b1;
|
|
<a name="l32"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e,*doc_e2;
|
|
<a name="l33"></a> </span><span class=cF9>I64</span><span class=cF0> renum_num=0;
|
|
<a name="l34"></a> b=doc->bin_head.next;
|
|
<a name="l35"></a> </span><span class=cF1>while</span><span class=cF0> (b!=&doc->bin_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l36"></a> b->use_cnt=0;
|
|
<a name="l37"></a> b->tmp_use_cnt=0;
|
|
<a name="l38"></a> b->renum_num=-1;
|
|
<a name="l39"></a> </span><span class=cF5>Free</span><span class=cF0>(b->tag);
|
|
<a name="l40"></a> b->tag=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l41"></a> b=b->next;
|
|
<a name="l42"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l43"></a> doc_e=doc->head.next;
|
|
<a name="l44"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l45"></a> doc_e2=doc_e->next;
|
|
<a name="l46"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->de_flags & </span><span class=cF3>DOCEF_HAS_BIN</span><span class=cF0>) {
|
|
<a name="l47"></a> </span><span class=cF1>if</span><span class=cF0> (b=doc_e->bin_data=</span><span class=cF5>DocBinFindNum</span><span class=cF7>(</span><span class=cF0>doc,doc_e->bin_num</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->de_flags & </span><span class=cF3>DOCEF_BIN_PTR_LINK</span><span class=cF0>)
|
|
<a name="l49"></a> b->tmp_use_cnt=</span><span class=cF3>I32_MAX</span><span class=cF0>;
|
|
<a name="l50"></a> </span><span class=cF1>if</span><span class=cF0> (!b->use_cnt++)
|
|
<a name="l51"></a> b->renum_num=++renum_num;
|
|
<a name="l52"></a> doc_e->bin_num=b->renum_num;
|
|
<a name="l53"></a> </span><span class=cF1>if</span><span class=cF0> (!b->tag && doc_e->de_flags&</span><span class=cF3>DOCEF_TAG</span><span class=cF0> && doc_e->tag && *doc_e->tag)
|
|
<a name="l54"></a> b->tag=</span><span class=cF5>StrNew</span><span class=cF0>(doc_e->tag,doc->mem_task);
|
|
<a name="l55"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l56"></a> </span><span class=cF5>RawPrint</span><span class=cF0>(3000,</span><span class=cF6>"Bin Not Found"</span><span class=cF0>);
|
|
<a name="l57"></a> doc_e->type=doc_e->de_flags=0;
|
|
<a name="l58"></a> doc_e->type_u8=</span><span class=cF3>DOCT_ERROR</span><span class=cF0>;
|
|
<a name="l59"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l60"></a> }
|
|
<a name="l61"></a> doc_e=doc_e2;
|
|
<a name="l62"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l63"></a>
|
|
<a name="l64"></a> b=doc->bin_head.next;
|
|
<a name="l65"></a> doc->cur_bin_num=1;
|
|
<a name="l66"></a> </span><span class=cF1>while</span><span class=cF0> (b!=&doc->bin_head) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l67"></a> b1=b->next;
|
|
<a name="l68"></a> </span><span class=cF1>if</span><span class=cF0> (!b->use_cnt) {
|
|
<a name="l69"></a> </span><span class=cF5>QueRem</span><span class=cF0>(b);
|
|
<a name="l70"></a> </span><span class=cF5>Free</span><span class=cF0>(b->data);
|
|
<a name="l71"></a> </span><span class=cF5>Free</span><span class=cF0>(b);
|
|
<a name="l72"></a> } </span><span class=cF1>else</span><span class=cF0> {
|
|
<a name="l73"></a> b->num=b->renum_num;
|
|
<a name="l74"></a> </span><span class=cF1>if</span><span class=cF0> (b->num>=doc->cur_bin_num)
|
|
<a name="l75"></a> doc->cur_bin_num=b->num+1;
|
|
<a name="l76"></a> }
|
|
<a name="l77"></a> b=b1;
|
|
<a name="l78"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l79"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
|
|
<a name="l80"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
|
|
<a name="l81"></a>}
|
|
<a name="l82"></a>
|
|
<a name="l83"></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="l84"></a>{
|
|
<a name="l85"></a> </span><span class=cF1>if</span><span class=cF0> (doc && b && b->use_cnt) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l86"></a> b->use_cnt--;
|
|
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (!b->use_cnt) {
|
|
<a name="l88"></a> </span><span class=cF5>QueRem</span><span class=cF0>(b);
|
|
<a name="l89"></a> </span><span class=cF5>Free</span><span class=cF0>(b->tag);
|
|
<a name="l90"></a> </span><span class=cF5>Free</span><span class=cF0>(b->data);
|
|
<a name="l91"></a> </span><span class=cF5>Free</span><span class=cF0>(b);
|
|
<a name="l92"></a> }
|
|
<a name="l93"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l94"></a> </span><span class=cF5>RawPrint</span><span class=cF0>(3000,</span><span class=cF6>"DocBinDel"</span><span class=cF0>);
|
|
<a name="l95"></a>}
|
|
<a name="l96"></a>
|
|
<a name="l97"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>DocBinPtrRst</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="l98"></a>{
|
|
<a name="l99"></a> </span><span class=cF1>U8</span><span class=cF0> *st,*st2;
|
|
<a name="l100"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc2;
|
|
<a name="l101"></a> </span><span class=cF9>CDocBin</span><span class=cF0> *tmpb,*tmpb2;
|
|
<a name="l102"></a> </span><span class=cF9>I64</span><span class=cF0> i,bin_num=0;
|
|
<a name="l103"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->de_flags&</span><span class=cF3>DOCEF_HAS_BIN</span><span class=cF0> &&
|
|
<a name="l104"></a> doc_e->bin_ptr_link && </span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>doc_e->bin_ptr_link</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l105"></a> bin_num=doc_e->bin_num;
|
|
<a name="l106"></a> st=</span><span class=cF5>StrNew</span><span class=cF0>(doc_e->bin_ptr_link);
|
|
<a name="l107"></a> st2=</span><span class=cF5>StrNew</span><span class=cF0>(st);
|
|
<a name="l108"></a> </span><span class=cF5>StrLastRem</span><span class=cF0>(st,</span><span class=cF6>","</span><span class=cF0>,st2);
|
|
<a name="l109"></a> i=</span><span class=cF5>Str2I64</span><span class=cF0>(st2);
|
|
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (i>0||*st2) {
|
|
<a name="l111"></a> doc2=</span><span class=cF5>DocRead</span><span class=cF0>(st);
|
|
<a name="l112"></a> </span><span class=cF1>if</span><span class=cF0> (i>0 && </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> ||
|
|
<a name="l113"></a> i==0 && </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>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l114"></a> i=1;
|
|
<a name="l115"></a> </span><span class=cF1>if</span><span class=cF0> (bin_num>0) {
|
|
<a name="l116"></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>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l117"></a> i=tmpb->use_cnt;
|
|
<a name="l118"></a> </span><span class=cF5>DocBinDel</span><span class=cF0>(doc,tmpb);
|
|
<a name="l119"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l120"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l121"></a> bin_num=doc->cur_bin_num++;
|
|
<a name="l122"></a> tmpb=</span><span class=cF5>MAllocIdent</span><span class=cF0>(tmpb2,doc->mem_task);
|
|
<a name="l123"></a> tmpb->use_cnt=i;
|
|
<a name="l124"></a> tmpb->data=</span><span class=cF5>MAllocIdent</span><span class=cF0>(tmpb2->data,doc->mem_task);
|
|
<a name="l125"></a> tmpb->num=bin_num;
|
|
<a name="l126"></a> doc_e->bin_data=tmpb;
|
|
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (doc_e->de_flags&</span><span class=cF3>DOCEF_TAG</span><span class=cF0> && doc_e->tag && *doc_e->tag)
|
|
<a name="l128"></a> tmpb->tag=</span><span class=cF5>StrNew</span><span class=cF0>(doc_e->tag,doc->mem_task);
|
|
<a name="l129"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l130"></a> tmpb->tag=</span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l131"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpb,doc->bin_head.last);
|
|
<a name="l132"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l133"></a> bin_num=0;
|
|
<a name="l134"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc2);
|
|
<a name="l135"></a> } </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l136"></a> bin_num=0;
|
|
<a name="l137"></a> </span><span class=cF5>Free</span><span class=cF0>(st2);
|
|
<a name="l138"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
|
|
<a name="l139"></a> doc_e->bin_num=bin_num;
|
|
<a name="l140"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l141"></a> </span><span class=cF1>return</span><span class=cF0> bin_num;
|
|
<a name="l142"></a>}
|
|
</span></pre></body>
|
|
</html>
|