templeos-info/public/Wb/Adam/Opt/Utils/LinkChk.HC.HTML

111 lines
9.4 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>&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>LinkChkDoc</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=0;
<a name="l10"></a> </span><span class=cF1>while</span><span class=cF0> (doc_e!=doc) </span><span class=cF7>{</span><span class=cF0>
<a name="l11"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>ScanKey</span><span class=cF0>) {
<a name="l12"></a> </span><span class=cF5>LBts</span><span class=cF0>(_fuf_flags,</span><span class=cF3>FUf_CANCEL</span><span class=cF0>);
<a name="l13"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l14"></a> }
<a name="l15"></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="l16"></a> old_doc=</span><span class=cF5>DocPut</span><span class=cF0>;
<a name="l17"></a> </span><span class=cF5>DocLock</span><span class=cF0>(old_doc);
<a name="l18"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;put_doc=doc;
<a name="l19"></a> found=</span><span class=cF5>DocLinkChk</span><span class=cF0>(doc,st);
<a name="l20"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;put_doc=old_doc;
<a name="l21"></a> </span><span class=cF5>DocUnlock</span><span class=cF0>(old_doc);
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (!found) </span><span class=cF7>{</span><span class=cF0>
<a name="l23"></a> </span><span class=cF5>PutFileLink</span><span class=cF0>(doc-&gt;filename.name,,doc_e-&gt;y);
<a name="l24"></a> </span><span class=cF6>&quot;$RED$ %04d:%s\n$FG$&quot;</span><span class=cF0>,doc_e-&gt;y,st;
<a name="l25"></a> res++;
<a name="l26"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l27"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l28"></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="l29"></a> </span><span class=cF5>PutFileLink</span><span class=cF0>(doc-&gt;filename.name,,doc_e-&gt;y);
<a name="l30"></a> </span><span class=cF6>&quot;$RED$ Doc Error\n$FG$&quot;</span><span class=cF0>;
<a name="l31"></a> res++;
<a name="l32"></a> }
<a name="l33"></a> doc_e=doc_e-&gt;next;
<a name="l34"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l35"></a> </span><span class=cF1>if</span><span class=cF0> (unlock) </span><span class=cF5>DocUnlock</span><span class=cF0>(doc);
<a name="l36"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l37"></a>}
<a name="l38"></a>
<a name="l39"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LinkChkFile</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="l40"></a>{
<a name="l41"></a> </span><span class=cF9>I64</span><span class=cF0> res;
<a name="l42"></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="l43"></a> res=</span><span class=cF5>LinkChkDoc</span><span class=cF0>(doc,_fuf_flags);
<a name="l44"></a> </span><span class=cF5>DocDel</span><span class=cF0>(doc);
<a name="l45"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l46"></a>}
<a name="l47"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>LinkChk</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="l48"></a>{</span><span class=cF2>//Check documents for broken file links.</span><span class=cF0>
<a name="l49"></a> </span><span class=cF9>I64</span><span class=cF0> fuf_flags=0,res=0;
<a name="l50"></a> </span><span class=cF9>CDirEntry</span><span class=cF0> *tmpde,*tmpde1;
<a name="l51"></a> </span><span class=cF1>U8</span><span class=cF0> *st;
<a name="l52"></a> </span><span class=cFB>progress2_max</span><span class=cF0>=1;
<a name="l53"></a> </span><span class=cF5>ScanFlags</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="l54"></a> </span><span class=cF5>ScanFlags</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="l55"></a> tmpde=tmpde1=</span><span class=cF5>FilesFind</span><span class=cF0>(files_find_mask,fuf_flags);
<a name="l56"></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>) </span><span class=cF7>{</span><span class=cF0>
<a name="l57"></a>
<a name="l58"></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="l59"></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>-1)
<a name="l60"></a> st[</span><span class=cF3>PROGRESS_DESC_LEN</span><span class=cF0>-1]=0;
<a name="l61"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(</span><span class=cFB>progress2_desc</span><span class=cF0>,st);
<a name="l62"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l63"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l64"></a>
<a name="l65"></a> res+=</span><span class=cF5>LinkChkFile</span><span class=cF0>(tmpde-&gt;full_name,&amp;fuf_flags);
<a name="l66"></a>
<a name="l67"></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="l68"></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>-1)
<a name="l69"></a> st[</span><span class=cF3>PROGRESS_DESC_LEN</span><span class=cF0>-1]=0;
<a name="l70"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(</span><span class=cFB>progress2_desc</span><span class=cF0>,st);
<a name="l71"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l72"></a> </span><span class=cF5>Yield</span><span class=cF0>;
<a name="l73"></a>
<a name="l74"></a> tmpde=tmpde-&gt;next;
<a name="l75"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l76"></a> </span><span class=cF5>DirTreeDel</span><span class=cF0>(tmpde1);
<a name="l77"></a> </span><span class=cFB>progress2_max</span><span class=cF0>=0;
<a name="l78"></a> </span><span class=cF1>return</span><span class=cF0> res;
<a name="l79"></a>}
</span></pre></body>
</html>