ZealOS/docs/Demo/DolDoc/FileRead.CC.html
2021-08-09 02:04:03 -04:00

112 lines
11 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.14">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<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,
<a name="l4"></a> *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="l5"></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> * </span><span class=cFE>64</span><span class=cF0>),
<a name="l6"></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> * </span><span class=cFE>64</span><span class=cF0>);
<a name="l7"></a> </span><span class=cF2>//Note: word wrap is determined by</span><span class=cF0>
<a name="l8"></a> </span><span class=cF2>//doc-&gt;win_task when a </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1502"><span class=cF4>CDoc</span></a><span class=cF2> is recalculated</span><span class=cF0>
<a name="l9"></a> </span><span class=cF2>//use </span><a href="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/DocRecalc.CC.html#l305"><span class=cF4>DocRecalc</span></a><span class=cF2>().</span><span class=cF0>
<a name="l10"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocRead</span><span class=cF0>(filename, flags);
<a name="l11"></a>
<a name="l12"></a> </span><span class=cF2>//doc-&gt;head which is equ to doc is the</span><span class=cF0>
<a name="l13"></a> </span><span class=cF2>//header of the CQueue and represents the end-of-file marker.</span><span class=cF0>
<a name="l14"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e = doc-&gt;head.next;
<a name="l15"></a>
<a name="l16"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l17"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l18"></a> cmd_stats[doc_e-&gt;type_u8]++;
<a name="l19"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFE>64</span><span class=cF0>; 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;de_flags, i</span><span class=cF7>)</span><span class=cF0>)
<a name="l21"></a> flags_stats[i]++;
<a name="l22"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>16</span><span class=cF0>; i &lt; </span><span class=cFE>32</span><span class=cF0>; i++)
<a name="l23"></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="l24"></a> type_flags_stats[i]++;
<a name="l25"></a> doc_e = doc_e-&gt;next;
<a name="l26"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l27"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l28"></a>
<a name="l29"></a> </span><span class=cF6>&quot;$PURPLE$-------%s-------\n&quot;</span><span class=cF0>, filename;
<a name="l30"></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="l31"></a> </span><span class=cF6>&quot;'$PURPLE$doc_e-&gt;type.u8[0]$GREEN$', &quot;</span><span class=cF0>
<a name="l32"></a> </span><span class=cF6>&quot;is cmd and accessed with the union &quot;</span><span class=cF0>
<a name="l33"></a> </span><span class=cF6>&quot;'$PURPLE$doc_e-&gt;type_u8$GREEN$'. &quot;</span><span class=cF0>
<a name="l34"></a> </span><span class=cF6>&quot;See $LK,\&quot;CDocEntry\&quot;,A=\&quot;MN:CDocEntry\&quot;$, &quot;</span><span class=cF0>
<a name="l35"></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="l36"></a> </span><span class=cF6>&quot;$LK,\&quot;Doc Type Codes\&quot;,&quot;</span><span class=cF0>
<a name="l37"></a> </span><span class=cF6>&quot;A=\&quot;FF:::/System/DolDoc/DocInit.CC,ST_DOC_CMDS\&quot;$.\n&quot;</span><span class=cF0>
<a name="l38"></a> </span><span class=cF6>&quot;$FG$&quot;</span><span class=cF0>;
<a name="l39"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cF3>DOCT_TYPES_NUM</span><span class=cF0>; i++)
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (cmd_stats[i])
<a name="l41"></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="l42"></a>
<a name="l43"></a> </span><span class=cF6>&quot;\n$GREEN$'$PURPLE$doc_e-&gt;type.u8[1]$GREEN$' is &quot;</span><span class=cF0>
<a name="l44"></a> </span><span class=cF6>&quot;the screen color attr of the &quot;</span><span class=cF0>
<a name="l45"></a> </span><span class=cF6>&quot;entry. '$PURPLE$doc_e-&gt;type.u16[1]&quot;</span><span class=cF0>
<a name="l46"></a> </span><span class=cF6>&quot;$GREEN$' is some flags for blinking and &quot;</span><span class=cF0>
<a name="l47"></a> </span><span class=cF6>&quot;stuff. See $LK,\&quot;Doc Type Flag &quot;</span><span class=cF0>
<a name="l48"></a> </span><span class=cF6>&quot;Defines\&quot;,A=\&quot;MN:DOCET_BLINK\&quot;$.\n$FG$&quot;</span><span class=cF0>;
<a name="l49"></a>
<a name="l50"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>16</span><span class=cF0>; i &lt; </span><span class=cFE>32</span><span class=cF0>; i++)
<a name="l51"></a> </span><span class=cF1>if</span><span class=cF0> (type_flags_stats[i])
<a name="l52"></a> </span><span class=cF6>&quot;%4d:%d\n&quot;</span><span class=cF0>, i, type_flags_stats[i];
<a name="l53"></a>
<a name="l54"></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="l55"></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="l56"></a> </span><span class=cF6>&quot;$LK,\&quot;Doc Flag Codes\&quot;,&quot;</span><span class=cF0>
<a name="l57"></a> </span><span class=cF6>&quot;A=\&quot;FF:::/System/DolDoc/DocInit.CC,ST_DOC_FLAGS\&quot;$.\n&quot;</span><span class=cF0>
<a name="l58"></a> </span><span class=cF6>&quot;$FG$&quot;</span><span class=cF0>;
<a name="l59"></a> </span><span class=cF1>for</span><span class=cF0> (i = </span><span class=cFE>0</span><span class=cF0>; i &lt; </span><span class=cFE>64</span><span class=cF0>; i++)
<a name="l60"></a> </span><span class=cF1>if</span><span class=cF0> (flags_stats[i])
<a name="l61"></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="l62"></a>
<a name="l63"></a> </span><span class=cF5>Free</span><span class=cF0>(cmd_stats);
<a name="l64"></a> </span><span class=cF5>Free</span><span class=cF0>(flags_stats);
<a name="l65"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l66"></a> </span><span class=cF6>'\n'</span><span class=cF0>;
<a name="l67"></a>}
<a name="l68"></a>
<a name="l69"></a></span><span class=cF2>/*See </span><a href="https://zeal-operating-system.github.io/ZealOS/System/Training.CC.html#l174"><span class=cF4>TipOfDay</span></a><span class=cF2>.</span><span class=cF0>
<a name="l70"></a>
<a name="l71"></a></span><span class=cF2>Note: Not all </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1326"><span class=cF4>CDocEntry</span></a><span class=cF2>'s are full-sized nodes.</span><span class=cF0>
<a name="l72"></a></span><span class=cF2>Some are </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/Memory/MAllocFree.CC.html#l391"><span class=cF4>MAlloc</span></a><span class=cF2>ed with a smaller size to save</span><span class=cF0>
<a name="l73"></a></span><span class=cF2>mem.</span><span class=cF0> </span><span class=cF2>They all have at least the size </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1303"><span class=cF4>CDocEntryBase</span></a><span class=cF2>.</span><span class=cF0>
<a name="l74"></a>
<a name="l75"></a></span><span class=cF2>Note: </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l1326"><span class=cF4>CDocEntry</span></a><span class=cF2>'s should be alloced from the</span><span class=cF0>
<a name="l76"></a></span><span class=cF2>heap of the owning task, doc-&gt;mem_task.</span><span class=cF0>
<a name="l77"></a>
<a name="l78"></a></span><span class=cF2>The flag arrays </span><a href="https://zeal-operating-system.github.io/ZealOS/System/DolDoc/MakeDoc.CC.html#l21"><span class=cF4>doldoc.type_flags_form</span></a><span class=cF2>, etc</span><span class=cF0>
<a name="l79"></a></span><span class=cF2>are useful.</span><span class=cF0>
<a name="l80"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l81"></a>
<a name="l82"></a>DocProfile(</span><span class=cF6>&quot;::/Doc/Welcome.DD&quot;</span><span class=cF0>, </span><span class=cFE>0</span><span class=cF0>);
<a name="l83"></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>