ZealOS/docs/Apps/TimeClock/TimeClk.CC.html
TomAwezome dbf8647d59 Fixed non-writable drive throw on F5 and Ctrl-S.
Added top & right borders to RawDr.
Improved spacing in some debug and compiler reporting.
Fixed RawPutChar and EdLite tab width.
Fixed Ui missing '0x' prefix syntax highlighter bug.
Added 32BitPaint demo.
2021-07-14 18:38:02 -04:00

199 lines
15 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.08">
<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:monospace;font-size:12pt">
<a name="l1"></a><span class=cF0>#</span><span class=cF1>define</span><span class=cF0> TIME_FILENAME </span><span class=cF6>&quot;~/TimeClock/TimeFile.DATA&quot;</span><span class=cF0>
<a name="l2"></a>
<a name="l3"></a>#</span><span class=cF1>define</span><span class=cF0> TET_EOF </span><span class=cFE>0</span><span class=cF0>
<a name="l4"></a>#</span><span class=cF1>define</span><span class=cF0> TET_PUNCH_IN </span><span class=cFE>1</span><span class=cF0>
<a name="l5"></a>#</span><span class=cF1>define</span><span class=cF0> TET_PUNCH_OUT </span><span class=cFE>2</span><span class=cF0>
<a name="l6"></a>
<a name="l7"></a></span><span class=cF1>class</span><span class=cF0> TimeEntry
<a name="l8"></a>{
<a name="l9"></a> TimeEntry *next, *last;
<a name="l10"></a> </span><span class=cF1>U8</span><span class=cF0> type;
<a name="l11"></a> </span><span class=cF9>CDate</span><span class=cF0> datetime;
<a name="l12"></a> </span><span class=cF1>U8</span><span class=cF0> *desc;
<a name="l13"></a>};
<a name="l14"></a>
<a name="l15"></a></span><span class=cF1>U0</span><span class=cF0> TimeFileRead(TimeEntry *header)
<a name="l16"></a>{
<a name="l17"></a> </span><span class=cF1>U8</span><span class=cF0> *buf, *ptr;
<a name="l18"></a> </span><span class=cF9>I64</span><span class=cF0> type;
<a name="l19"></a> TimeEntry *tmpt;
<a name="l20"></a>
<a name="l21"></a> buf = </span><span class=cF5>FileRead</span><span class=cF0>(TIME_FILENAME);
<a name="l22"></a> </span><span class=cF1>if</span><span class=cF0> (!buf)
<a name="l23"></a> buf = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l24"></a> </span><span class=cF5>QueueInit</span><span class=cF0>(header);
<a name="l25"></a> ptr = buf;
<a name="l26"></a> </span><span class=cF1>while</span><span class=cF0> (type = *ptr++)
<a name="l27"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l28"></a> tmpt = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
<a name="l29"></a> tmpt-&gt;type = type;
<a name="l30"></a> tmpt-&gt;datetime = *ptr(</span><span class=cF9>CDate</span><span class=cF0> *)++;
<a name="l31"></a> tmpt-&gt;desc = </span><span class=cF5>StrNew</span><span class=cF0>(ptr);
<a name="l32"></a> ptr += </span><span class=cF5>StrLen</span><span class=cF0>(ptr) + </span><span class=cFE>1</span><span class=cF0>;
<a name="l33"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpt, header-&gt;last);
<a name="l34"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l35"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l36"></a>}
<a name="l37"></a>
<a name="l38"></a></span><span class=cF1>U0</span><span class=cF0> TimeFileWrite(TimeEntry *header)
<a name="l39"></a>{
<a name="l40"></a> </span><span class=cF1>U8</span><span class=cF0> *buf, *ptr;
<a name="l41"></a> TimeEntry *tmpt;
<a name="l42"></a> </span><span class=cF9>I64</span><span class=cF0> size = </span><span class=cFE>1</span><span class=cF0>; </span><span class=cF2>//for EOF</span><span class=cF0>
<a name="l43"></a>
<a name="l44"></a> tmpt = header-&gt;next;
<a name="l45"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != header)
<a name="l46"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l47"></a> size += </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0>) + </span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>CDate</span><span class=cF0>) + </span><span class=cF5>StrLen</span><span class=cF0>(tmpt-&gt;desc) + </span><span class=cFE>1</span><span class=cF0>;
<a name="l48"></a> tmpt = tmpt-&gt;next;
<a name="l49"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l50"></a> buf = </span><span class=cF5>MAlloc</span><span class=cF0>(size);
<a name="l51"></a>
<a name="l52"></a> ptr = buf;
<a name="l53"></a> tmpt = header-&gt;next;
<a name="l54"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != header)
<a name="l55"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l56"></a> *ptr+ += tmpt-&gt;type;
<a name="l57"></a> *ptr(</span><span class=cF9>CDate</span><span class=cF0> *)++ = tmpt-&gt;datetime;
<a name="l58"></a> </span><span class=cF5>StrCopy</span><span class=cF0>(ptr, tmpt-&gt;desc);
<a name="l59"></a> ptr += </span><span class=cF5>StrLen</span><span class=cF0>(tmpt-&gt;desc) + </span><span class=cFE>1</span><span class=cF0>;
<a name="l60"></a> tmpt = tmpt-&gt;next;
<a name="l61"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l62"></a> *ptr = TET_EOF;
<a name="l63"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(TIME_FILENAME, buf, size);
<a name="l64"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
<a name="l65"></a>}
<a name="l66"></a>
<a name="l67"></a></span><span class=cF1>U0</span><span class=cF0> TimeEntriesDel(TimeEntry *header)
<a name="l68"></a>{
<a name="l69"></a> TimeEntry *tmpt = header-&gt;next, *tmpt1;
<a name="l70"></a>
<a name="l71"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != header)
<a name="l72"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l73"></a> tmpt1 = tmpt-&gt;next;
<a name="l74"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpt-&gt;desc);
<a name="l75"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpt);
<a name="l76"></a> tmpt = tmpt1;
<a name="l77"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l78"></a> </span><span class=cF5>Free</span><span class=cF0>(header);
<a name="l79"></a>}
<a name="l80"></a>
<a name="l81"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>Bool</span><span class=cF0> TimeRep(TimeEntry **_header=</span><span class=cF3>NULL</span><span class=cF0>)
<a name="l82"></a>{
<a name="l83"></a> </span><span class=cF1>Bool</span><span class=cF0> is_in = </span><span class=cF3>FALSE</span><span class=cF0>, first = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l84"></a> </span><span class=cF9>I64</span><span class=cF0> week, cur_week = -</span><span class=cFE>1</span><span class=cF0>, week_total;
<a name="l85"></a> TimeEntry *tmpt, *header = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
<a name="l86"></a>
<a name="l87"></a> </span><span class=cF1>if</span><span class=cF0> (_header)
<a name="l88"></a> *_header = header;
<a name="l89"></a> TimeFileRead(header);
<a name="l90"></a> tmpt = header-&gt;next;
<a name="l91"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt != header)
<a name="l92"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l93"></a> week = tmpt-&gt;datetime.date / </span><span class=cFE>7</span><span class=cF0>; </span><span class=cF2>//TODO</span><span class=cF0>
<a name="l94"></a> </span><span class=cF1>if</span><span class=cF0> (week != cur_week)
<a name="l95"></a> {
<a name="l96"></a> </span><span class=cF1>if</span><span class=cF0> (!first)
<a name="l97"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l98"></a> </span><span class=cF1>if</span><span class=cF0> (is_in)
<a name="l99"></a> week_total += </span><span class=cF5>Now</span><span class=cF0>;
<a name="l100"></a> </span><span class=cF6>&quot;Week Total:%T\n&quot;</span><span class=cF0>, week_total - </span><span class=cFB>local_time_offset</span><span class=cF0>;
<a name="l101"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l102"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l103"></a> first = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l104"></a> cur_week = week;
<a name="l105"></a> week_total = </span><span class=cFE>0</span><span class=cF0>;
<a name="l106"></a> }
<a name="l107"></a> </span><span class=cF1>if</span><span class=cF0> (tmpt-&gt;type == TET_PUNCH_IN)
<a name="l108"></a> {
<a name="l109"></a> </span><span class=cF6>&quot;$RED$IN &quot;</span><span class=cF0>;
<a name="l110"></a> </span><span class=cF1>if</span><span class=cF0> (!is_in)
<a name="l111"></a> week_total -= tmpt-&gt;datetime;
<a name="l112"></a> is_in = </span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l113"></a> }
<a name="l114"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l115"></a> {
<a name="l116"></a> </span><span class=cF6>&quot;$RED$OUT&quot;</span><span class=cF0>;
<a name="l117"></a> </span><span class=cF1>if</span><span class=cF0> (is_in)
<a name="l118"></a> week_total += tmpt-&gt;datetime;
<a name="l119"></a> is_in = </span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l120"></a> }
<a name="l121"></a> </span><span class=cF6>&quot; %D %T:$FG$\n%s\n&quot;</span><span class=cF0>, tmpt-&gt;datetime, tmpt-&gt;datetime, tmpt-&gt;desc;
<a name="l122"></a> tmpt = tmpt-&gt;next;
<a name="l123"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l124"></a> </span><span class=cF1>if</span><span class=cF0> (is_in)
<a name="l125"></a> week_total += </span><span class=cF5>Now</span><span class=cF0>;
<a name="l126"></a> </span><span class=cF6>&quot;$RED$Week Total:%T$FG$\n&quot;</span><span class=cF0>, week_total - </span><span class=cFB>local_time_offset</span><span class=cF0>;
<a name="l127"></a> </span><span class=cF1>if</span><span class=cF0> (!_header)
<a name="l128"></a> TimeEntriesDel(header);
<a name="l129"></a> </span><span class=cF1>return</span><span class=cF0> is_in;
<a name="l130"></a>}
<a name="l131"></a>
<a name="l132"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> PunchOut()
<a name="l133"></a>{
<a name="l134"></a> TimeEntry *tmpt, *header;
<a name="l135"></a>
<a name="l136"></a> </span><span class=cF1>if</span><span class=cF0> (!TimeRep</span><span class=cF7>(</span><span class=cF0>&amp;header</span><span class=cF7>)</span><span class=cF0>)
<a name="l137"></a> </span><span class=cF6>&quot;$BK,1$Already Punched-Out$BK,0$\n&quot;</span><span class=cF0>;
<a name="l138"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l139"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l140"></a> tmpt = </span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
<a name="l141"></a> tmpt-&gt;type = TET_PUNCH_OUT;
<a name="l142"></a> tmpt-&gt;datetime = </span><span class=cF5>Now</span><span class=cF0>;
<a name="l143"></a> </span><span class=cF6>&quot;\nEnter Description.\nPress &lt;ESC&gt; when done.\n&quot;</span><span class=cF0>;
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpt-&gt;desc = </span><span class=cF5>StrGet</span><span class=cF0>(,, </span><span class=cF3>SGF_WITH_NEW_LINE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l145"></a> tmpt-&gt;desc = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l146"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpt, header-&gt;last);
<a name="l147"></a> TimeFileWrite(header);
<a name="l148"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l149"></a> TimeEntriesDel(header);
<a name="l150"></a>}
<a name="l151"></a>
<a name="l152"></a></span><span class=cF1>public</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> PunchIn()
<a name="l153"></a>{
<a name="l154"></a> TimeEntry *tmpt, *header;
<a name="l155"></a>
<a name="l156"></a> </span><span class=cF1>if</span><span class=cF0> (TimeRep</span><span class=cF7>(</span><span class=cF0>&amp;header</span><span class=cF7>)</span><span class=cF0>)
<a name="l157"></a> </span><span class=cF6>&quot;$BK,1$Already Punched-In$BK,0$\n&quot;</span><span class=cF0>;
<a name="l158"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l159"></a> </span><span class=cF7>{</span><span class=cF0>
<a name="l160"></a> tmpt=</span><span class=cF5>MAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>TimeEntry</span><span class=cF7>)</span><span class=cF0>);
<a name="l161"></a> tmpt-&gt;type = TET_PUNCH_IN;
<a name="l162"></a> tmpt-&gt;datetime = </span><span class=cF5>Now</span><span class=cF0>;
<a name="l163"></a> </span><span class=cF6>&quot;\nEnter Description.\nPress &lt;ESC&gt; when done.\n&quot;</span><span class=cF0>;
<a name="l164"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>tmpt-&gt;desc = </span><span class=cF5>StrGet</span><span class=cF0>(,, </span><span class=cF3>SGF_WITH_NEW_LINE</span><span class=cF0>)</span><span class=cF7>)</span><span class=cF0>)
<a name="l165"></a> tmpt-&gt;desc = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cFE>1</span><span class=cF0>);
<a name="l166"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(tmpt, header-&gt;last);
<a name="l167"></a> TimeFileWrite(header);
<a name="l168"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l169"></a> TimeEntriesDel(header);
<a name="l170"></a>}
</span></pre></body>
</html>