templeos-info/public/Wb/Demo/DolDoc/FileRead.HC.HTML

112 lines
10 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=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> DocProfile(</span><span class=cF1>U8</span><span class=cF0> *filename,</span><span class=cF9>I64</span><span class=cF0> flags)
<a name="l2"></a>{
<a name="l3"></a> </span><span class=cF9>I64</span><span class=cF0> i,*cmd_stats=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>*</span><span class=cF3>DOCT_TYPES_NUM</span><span class=cF0>),
<a name="l4"></a> *flags_stats=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>*64),
<a name="l5"></a> *type_flags_stats=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>*64);
<a name="l6"></a></span><span class=cF2>//Note: word wrap is determined by</span><span class=cF0>
<a name="l7"></a> </span><span class=cF2>//doc-&gt;win_task when a </span><a href="/Wb/Kernel/KernelA.HH.HTML#l1367"><span class=cF4>CDoc</span></a><span class=cF2> is recalculated</span><span class=cF0>
<a name="l8"></a> </span><span class=cF2>//use </span><a href="/Wb/Adam/DolDoc/DocRecalc.HC.HTML#l256"><span class=cF4>DocRecalc</span></a><span class=cF2>().</span><span class=cF0>
<a name="l9"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc=</span><span class=cF5>DocRead</span><span class=cF0>(filename,flags);
<a name="l10"></a>
<a name="l11"></a> </span><span class=cF2>//doc-&gt;head which is equ to doc is the</span><span class=cF0>
<a name="l12"></a> </span><span class=cF2>//header of the CQue and represents the end-of-file marker.</span><span class=cF0>
<a name="l13"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e=doc-&gt;head.next;
<a name="l14"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
<a name="l15"></a> cmd_stats[doc_e-&gt;type_u8]++;
<a name="l16"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;64;i++)
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;doc_e-&gt;de_flags,i</span><span class=cF7>)</span><span class=cF0>)
<a name="l18"></a> flags_stats[i]++;
<a name="l19"></a> </span><span class=cF1>for</span><span class=cF0> (i=16;i&lt;32;i++)
<a name="l20"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;doc_e-&gt;type,i</span><span class=cF7>)</span><span class=cF0>)
<a name="l21"></a> type_flags_stats[i]++;
<a name="l22"></a> doc_e=doc_e-&gt;next;
<a name="l23"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l24"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l25"></a>
<a name="l26"></a> </span><span class=cF6>&quot;$PURPLE$-------%s-------\n&quot;</span><span class=cF0>,filename;
<a name="l27"></a> </span><span class=cF6>&quot;$GREEN$The lowest byte of the 32-bit 'doc_e-&gt;type', &quot;</span><span class=cF0>
<a name="l28"></a> </span><span class=cF6>&quot;'$PURPLE$doc_e-&gt;type.u8[0]$GREEN$', &quot;</span><span class=cF0>
<a name="l29"></a> </span><span class=cF6>&quot;is cmd and accessed with the union &quot;</span><span class=cF0>
<a name="l30"></a> </span><span class=cF6>&quot;'$PURPLE$doc_e-&gt;type_u8$GREEN$'. &quot;</span><span class=cF0>
<a name="l31"></a> </span><span class=cF6>&quot;See $LK,\&quot;CDocEntry\&quot;,A=\&quot;MN:CDocEntry\&quot;$, &quot;</span><span class=cF0>
<a name="l32"></a> </span><span class=cF6>&quot;$LK,\&quot;Doc Type Defines\&quot;,A=\&quot;MN:DOCT_TEXT\&quot;$ and &quot;</span><span class=cF0>
<a name="l33"></a> </span><span class=cF6>&quot;$LK,\&quot;Doc Type Codes\&quot;,&quot;</span><span class=cF0>
<a name="l34"></a> </span><span class=cF6>&quot;A=\&quot;FF:::/Adam/DolDoc/DocInit.HC,ST_DOC_CMDS\&quot;$.\n&quot;</span><span class=cF0>
<a name="l35"></a> </span><span class=cF6>&quot;$FG$&quot;</span><span class=cF0>;
<a name="l36"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;</span><span class=cF3>DOCT_TYPES_NUM</span><span class=cF0>;i++)
<a name="l37"></a> </span><span class=cF1>if</span><span class=cF0> (cmd_stats[i])
<a name="l38"></a> </span><span class=cF6>&quot;%4Z:%d\n&quot;</span><span class=cF0>,i,</span><span class=cF6>&quot;ST_DOC_CMDS&quot;</span><span class=cF0>,cmd_stats[i];
<a name="l39"></a>
<a name="l40"></a> </span><span class=cF6>&quot;\n$GREEN$'$PURPLE$doc_e-&gt;type.u8[1]$GREEN$' is &quot;</span><span class=cF0>
<a name="l41"></a> </span><span class=cF6>&quot;the scrn color attr of the &quot;</span><span class=cF0>
<a name="l42"></a> </span><span class=cF6>&quot;entry. '$PURPLE$doc_e-&gt;type.u16[1]&quot;</span><span class=cF0>
<a name="l43"></a> </span><span class=cF6>&quot;$GREEN$' is some flags for blinking and &quot;</span><span class=cF0>
<a name="l44"></a> </span><span class=cF6>&quot;stuff. See $LK,\&quot;Doc Type Flag &quot;</span><span class=cF0>
<a name="l45"></a> </span><span class=cF6>&quot;Defines\&quot;,A=\&quot;MN:DOCET_BLINK\&quot;$.\n$FG$&quot;</span><span class=cF0>;
<a name="l46"></a>
<a name="l47"></a> </span><span class=cF1>for</span><span class=cF0> (i=16;i&lt;32;i++)
<a name="l48"></a> </span><span class=cF1>if</span><span class=cF0> (type_flags_stats[i])
<a name="l49"></a> </span><span class=cF6>&quot;%4d:%d\n&quot;</span><span class=cF0>,i,type_flags_stats[i];
<a name="l50"></a>
<a name="l51"></a> </span><span class=cF6>&quot;$GREEN$\n'$PURPLE$doc_e-&gt;de_flags$GREEN$' is 64-bit. &quot;</span><span class=cF0>
<a name="l52"></a> </span><span class=cF6>&quot;See $LK,\&quot;Doc Flag Defines\&quot;,A=\&quot;MN:DOCEf_TAG\&quot;$ and &quot;</span><span class=cF0>
<a name="l53"></a> </span><span class=cF6>&quot;$LK,\&quot;Doc Flag Codes\&quot;,&quot;</span><span class=cF0>
<a name="l54"></a> </span><span class=cF6>&quot;A=\&quot;FF:::/Adam/DolDoc/DocInit.HC,ST_DOC_FLAGS\&quot;$.\n&quot;</span><span class=cF0>
<a name="l55"></a> </span><span class=cF6>&quot;$FG$&quot;</span><span class=cF0>;
<a name="l56"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;64;i++)
<a name="l57"></a> </span><span class=cF1>if</span><span class=cF0> (flags_stats[i])
<a name="l58"></a> </span><span class=cF6>&quot;%4Z:%d\n&quot;</span><span class=cF0>,i,</span><span class=cF6>&quot;ST_DOC_FLAGS&quot;</span><span class=cF0>,flags_stats[i];
<a name="l59"></a>
<a name="l60"></a> </span><span class=cF5>Free</span><span class=cF0>(cmd_stats);
<a name="l61"></a> </span><span class=cF5>Free</span><span class=cF0>(flags_stats);
<a name="l62"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l63"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l64"></a>}
<a name="l65"></a>
<a name="l66"></a></span><span class=cF2>/*See </span><a href="/Wb/Adam/Training.HC.HTML#l161"><span class=cF4>TipOfDay</span></a><span class=cF2>.</span><span class=cF0>
<a name="l67"></a>
<a name="l68"></a></span><span class=cF2>Note: Not all </span><a href="/Wb/Kernel/KernelA.HH.HTML#l1191"><span class=cF4>CDocEntry</span></a><span class=cF2>'s are full-sized nodes.</span><span class=cF0>
<a name="l69"></a></span><span class=cF2>Some are </span><a href="/Wb/Kernel/Mem/MAllocFree.HC.HTML#l387"><span class=cF4>MAlloc</span></a><span class=cF2>ed with a smaller size to save</span><span class=cF0>
<a name="l70"></a></span><span class=cF2>mem.</span><span class=cF0> </span><span class=cF2>They all have at least the size </span><a href="/Wb/Kernel/KernelA.HH.HTML#l1169"><span class=cF4>CDocEntryBase</span></a><span class=cF2>.</span><span class=cF0>
<a name="l71"></a>
<a name="l72"></a></span><span class=cF2>Note: </span><a href="/Wb/Kernel/KernelA.HH.HTML#l1191"><span class=cF4>CDocEntry</span></a><span class=cF2>'s should be alloced from the</span><span class=cF0>
<a name="l73"></a></span><span class=cF2>heap of the owning task, doc-&gt;mem_task.</span><span class=cF0>
<a name="l74"></a>
<a name="l75"></a></span><span class=cF2>The flag arrays </span><a href="/Wb/Adam/DolDoc/MakeDoc.HC.HTML#l21"><span class=cF4>doldoc.type_flags_form</span></a><span class=cF2>, etc</span><span class=cF0>
<a name="l76"></a></span><span class=cF2>are useful.</span><span class=cF0>
<a name="l77"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l78"></a>
<a name="l79"></a>DocProfile(</span><span class=cF6>&quot;::/Doc/Welcome.DD&quot;</span><span class=cF0>,0);
<a name="l80"></a>DocProfile(</span><span class=cF6>&quot;::/Doc/Welcome.DD&quot;</span><span class=cF0>,</span><span class=cF3>DOCF_PLAIN_TEXT</span><span class=cF0>);
</span></pre></body>
</html>