ZealOS/docs/System/Utils/LinkCheck.html
2021-07-03 00:07:57 -04:00

122 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.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;Debugging;Cmd Line (Typically)&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LinkCheckDoc</span><span class=cF0>(</span><span class=cF9>CDoc</span><span class=cF0> *doc, </span><span class=cF9>I64</span><span class=cF0> *_fuf_flags)
<a name="l4"></a>{
<a name="l5"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l6"></a> </span><span class=cF1>Bool</span><span class=cF0> found, unlock = </span><span class=cF5>DocLock</span><span class=cF0>(doc);
<a name="l7"></a> </span><span class=cF9>CDoc</span><span class=cF0> *old_doc;
<a name="l8"></a> </span><span class=cF9>CDocEntry</span><span class=cF0> *doc_e = doc-&gt;head.next;
<a name="l9"></a> </span><span class=cF9>I64</span><span class=cF0> res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l10"></a>
<a name="l11"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e != doc)
<a name="l12"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l13"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>KeyScan</span><span class=cF0>)
<a name="l14"></a> {
<a name="l15"></a> </span><span class=cF5>LBts</span><span class=cF0>(_fuf_flags, </span><span class=cF3>FUf_CANCEL</span><span class=cF0>);
<a name="l16"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l17"></a> }
<a name="l18"></a> </span><span class=cF1>if</span><span class=cF0> (st = </span><span class=cF5>DocEntryLink</span><span class=cF7>(</span><span class=cF0>doc, doc_e</span><span class=cF7>)</span><span class=cF0>)
<a name="l19"></a> {
<a name="l20"></a> old_doc = </span><span class=cF5>DocPut</span><span class=cF0>;
<a name="l21"></a> </span><span class=cF5>DocLock</span><span class=cF0>(old_doc);
<a name="l22"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;put_doc = doc;
<a name="l23"></a> found = </span><span class=cF5>DocLinkCheck</span><span class=cF0>(doc, st);
<a name="l24"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;put_doc = old_doc;
<a name="l25"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(old_doc);
<a name="l26"></a> </span><span class=cF1>if</span><span class=cF0> (!found)
<a name="l27"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l28"></a> </span><span class=cF5>PutFileLink</span><span class=cF0>(doc-&gt;filename.name,, doc_e-&gt;y);
<a name="l29"></a> </span><span class=cF6>&quot;$RED$ %04d:%s\n$FG$&quot;</span><span class=cF0>, doc_e-&gt;y, st;
<a name="l30"></a> res++;
<a name="l31"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l32"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l33"></a> }
<a name="l34"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (doc_e-&gt;type_u8 == </span><span class=cF3>DOCT_ERROR</span><span class=cF0>)
<a name="l35"></a> {
<a name="l36"></a> </span><span class=cF5>PutFileLink</span><span class=cF0>(doc-&gt;filename.name,, doc_e-&gt;y);
<a name="l37"></a> </span><span class=cF6>&quot;$RED$ Doc Error\n$FG$&quot;</span><span class=cF0>;
<a name="l38"></a> res++;
<a name="l39"></a> }
<a name="l40"></a> doc_e = doc_e-&gt;next;
<a name="l41"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l42"></a> </span><span class=cF1>if</span><span class=cF0> (unlock)
<a name="l43"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l44"></a>
<a name="l45"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l46"></a>}
<a name="l47"></a>
<a name="l48"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LinkCheckFile</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *filename, </span><span class=cF9>I64</span><span class=cF0> *_fuf_flags)
<a name="l49"></a>{
<a name="l50"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l51"></a> </span><span class=cF9>CDoc</span><span class=cF0> *doc = </span><span class=cF5>DocRead</span><span class=cF0>(filename, </span><span class=cF3>DOCF_NO_CURSOR</span><span class=cF0>);
<a name="l52"></a>
<a name="l53"></a> res = </span><span class=cF5>LinkCheckDoc</span><span class=cF0>(doc, _fuf_flags);
<a name="l54"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l55"></a>
<a name="l56"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l57"></a>}
<a name="l58"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LinkCheck</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> *files_find_mask=</span><span class=cF6>&quot;/*&quot;</span><span class=cF0>, </span><span class=cF1>U8</span><span class=cF0> *fu_flags=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l59"></a>{</span><span class=cF2>//Check documents for broken file links.</span><span class=cF0>
<a name="l60"></a> </span><span class=cF9>I64</span><span class=cF0> fuf_flags = </span><span class=cFE>0</span><span class=cF0>, res = </span><span class=cFE>0</span><span class=cF0>;
<a name="l61"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde, *tmpde1;
<a name="l62"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l63"></a>
<a name="l64"></a> </span><span class=cFB>progress2_max</span><span class=cF0> = </span><span class=cFE>1</span><span class=cF0>;
<a name="l65"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, </span><span class=cF6>&quot;+r+$+f+F+O&quot;</span><span class=cF0>);
<a name="l66"></a> </span><span class=cF5>FlagsScan</span><span class=cF0>(&amp;fuf_flags, </span><span class=cF5>Define</span><span class=cF7>(</span><span class=cF6>&quot;ST_FILE_UTIL_FLAGS&quot;</span><span class=cF7>)</span><span class=cF0>, fu_flags);
<a name="l67"></a> tmpde = tmpde1 = </span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask, fuf_flags);
<a name="l68"></a> </span><span class=cF1>while</span><span class=cF0> (tmpde &amp;&amp; !</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;fuf_flags, </span><span class=cF3>FUf_CANCEL</span><span class=cF7>)</span><span class=cF0>)
<a name="l69"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l70"></a>
<a name="l71"></a> st = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;Before %s Broke:%d&quot;</span><span class=cF0>, tmpde-&gt;full_name, res);
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>st</span><span class=cF7>)</span><span class=cF0> &gt; </span><span class=cF3>PROGRESS_DESC_LEN</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>)
<a name="l73"></a> st[</span><span class=cF3>PROGRESS_DESC_LEN</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l74"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(</span><span class=cFB>progress2_desc</span><span class=cF0>, st);
<a name="l75"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l76"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l77"></a>
<a name="l78"></a> res += </span><span class=cF5>LinkCheckFile</span><span class=cF0>(tmpde-&gt;full_name, &amp;fuf_flags);
<a name="l79"></a>
<a name="l80"></a> st = </span><span class=cF5>MStrPrint</span><span class=cF0>(</span><span class=cF6>&quot;After %s Broke:%d&quot;</span><span class=cF0>, tmpde-&gt;full_name, res);
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>st</span><span class=cF7>)</span><span class=cF0> &gt; </span><span class=cF3>PROGRESS_DESC_LEN</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>)
<a name="l82"></a> st[</span><span class=cF3>PROGRESS_DESC_LEN</span><span class=cF0> - </span><span class=cFE>1</span><span class=cF0>] = </span><span class=cFE>0</span><span class=cF0>;
<a name="l83"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(</span><span class=cFB>progress2_desc</span><span class=cF0>, st);
<a name="l84"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l85"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l86"></a>
<a name="l87"></a> tmpde = tmpde-&gt;next;
<a name="l88"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l89"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
<a name="l90"></a> </span><span class=cFB>progress2_max</span><span class=cF0> = </span><span class=cFE>0</span><span class=cF0>;
<a name="l91"></a>
<a name="l92"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l93"></a>}
</span></pre></body>
</html>