172 lines
12 KiB
Plaintext
172 lines
12 KiB
Plaintext
|
<!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>U0</span><span class=cF0> BgtDataRead()
|
||
|
<a name="l2"></a>{
|
||
|
<a name="l3"></a> CBgtEntry *tmpb;
|
||
|
<a name="l4"></a> CBgtTemplate *tmpt;
|
||
|
<a name="l5"></a> </span><span class=cF9>I64</span><span class=cF0> i,cnt,size;
|
||
|
<a name="l6"></a> </span><span class=cF1>U8</span><span class=cF0> *b,*ptr;
|
||
|
<a name="l7"></a> </span><span class=cF9>I64</span><span class=cF0> max_num;
|
||
|
<a name="l8"></a> </span><span class=cF1>U8</span><span class=cF0> **s=StrFileRead(bgt_string_file,&max_num);
|
||
|
<a name="l9"></a>
|
||
|
<a name="l10"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&b_head,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CBgtEntry</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l11"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&b_head);
|
||
|
<a name="l12"></a> b_head.date=</span><span class=cF5>Now</span><span class=cF0>;
|
||
|
<a name="l13"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&t_head,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CBgtTemplate</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l14"></a> </span><span class=cF5>QueInit</span><span class=cF0>(&t_head);
|
||
|
<a name="l15"></a> t_head.b.date=</span><span class=cF5>Now</span><span class=cF0>;
|
||
|
<a name="l16"></a>
|
||
|
<a name="l17"></a> </span><span class=cF1>if</span><span class=cF0> (ptr=b=</span><span class=cF5>FileRead</span><span class=cF7>(</span><span class=cF0>bgt_data_file,&size</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l18"></a> cnt=*ptr(</span><span class=cF9>I64</span><span class=cF0> *)++;
|
||
|
<a name="l19"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<cnt;i++) {
|
||
|
<a name="l20"></a> tmpb=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CBgtEntry</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l21"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&tmpb-></span><span class=cF1>start</span><span class=cF0>,ptr,BE_SIZE);
|
||
|
<a name="l22"></a> tmpb->credit=</span><span class=cF5>StrNew</span><span class=cF0>(s[tmpb->credit_idx]);
|
||
|
<a name="l23"></a> tmpb->debit =</span><span class=cF5>StrNew</span><span class=cF0>(s[tmpb->debit_idx]);
|
||
|
<a name="l24"></a> tmpb->desc =</span><span class=cF5>StrNew</span><span class=cF0>(s[tmpb->desc_idx]);
|
||
|
<a name="l25"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpb,b_head.last);
|
||
|
<a name="l26"></a> ptr+=BE_SIZE;
|
||
|
<a name="l27"></a> }
|
||
|
<a name="l28"></a>
|
||
|
<a name="l29"></a> cnt=*ptr(</span><span class=cF9>I64</span><span class=cF0> *)++;
|
||
|
<a name="l30"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<cnt;i++) {
|
||
|
<a name="l31"></a> tmpt=</span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CBgtTemplate</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l32"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&tmpt-></span><span class=cF1>start</span><span class=cF0>,ptr,BT_SIZE);
|
||
|
<a name="l33"></a> ptr+=BT_SIZE;
|
||
|
<a name="l34"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(&tmpt->b.</span><span class=cF1>start</span><span class=cF0>,ptr,BE_SIZE);
|
||
|
<a name="l35"></a> ptr+=BE_SIZE;
|
||
|
<a name="l36"></a> tmpt->b.credit=</span><span class=cF5>StrNew</span><span class=cF0>(s[tmpt->b.credit_idx]);
|
||
|
<a name="l37"></a> tmpt->b.debit =</span><span class=cF5>StrNew</span><span class=cF0>(s[tmpt->b.debit_idx]);
|
||
|
<a name="l38"></a> tmpt->b.desc =</span><span class=cF5>StrNew</span><span class=cF0>(s[tmpt->b.desc_idx]);
|
||
|
<a name="l39"></a> </span><span class=cF5>QueIns</span><span class=cF0>(tmpt,t_head.last);
|
||
|
<a name="l40"></a> }
|
||
|
<a name="l41"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l42"></a>
|
||
|
<a name="l43"></a> StrFileArrDel(s,max_num);
|
||
|
<a name="l44"></a> </span><span class=cF5>Free</span><span class=cF0>(b);
|
||
|
<a name="l45"></a>
|
||
|
<a name="l46"></a> BgtAcctsUpdate;
|
||
|
<a name="l47"></a>}
|
||
|
<a name="l48"></a>
|
||
|
<a name="l49"></a></span><span class=cF1>U0</span><span class=cF0> BgtDataWrite()
|
||
|
<a name="l50"></a>{
|
||
|
<a name="l51"></a> </span><span class=cF9>I64</span><span class=cF0> i,num=0,size,cnt1,cnt2;
|
||
|
<a name="l52"></a> </span><span class=cF9>CHashTable</span><span class=cF0> *table=</span><span class=cF5>HashTableNew</span><span class=cF0>(1024);
|
||
|
<a name="l53"></a> CBgtEntry *tmpb;
|
||
|
<a name="l54"></a> CBgtTemplate *tmpt;
|
||
|
<a name="l55"></a> </span><span class=cF9>CHashGeneric</span><span class=cF0> *tmph;
|
||
|
<a name="l56"></a> </span><span class=cF1>U8</span><span class=cF0> *buf,*ptr;
|
||
|
<a name="l57"></a>
|
||
|
<a name="l58"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i<=accts_table->mask;i++) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l59"></a> tmph=accts_table->body[i];
|
||
|
<a name="l60"></a> </span><span class=cF1>while</span><span class=cF0> (tmph) {
|
||
|
<a name="l61"></a> StrFileAdd(tmph->str,&num,table); </span><span class=cF2>//Cosmetics -- make accts appear first.</span><span class=cF0>
|
||
|
<a name="l62"></a> tmph=tmph->next;
|
||
|
<a name="l63"></a> }
|
||
|
<a name="l64"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l65"></a>
|
||
|
<a name="l66"></a> tmpb=b_head.next;
|
||
|
<a name="l67"></a> cnt1=0;
|
||
|
<a name="l68"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&b_head) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l69"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb->type!=BE_TEMPLATE_COPY) {
|
||
|
<a name="l70"></a> tmpb->credit_idx =StrFileAdd(tmpb->credit,&num,table);
|
||
|
<a name="l71"></a> tmpb->debit_idx =StrFileAdd(tmpb->debit,&num,table);
|
||
|
<a name="l72"></a> tmpb->desc_idx =StrFileAdd(tmpb->desc,&num,table);
|
||
|
<a name="l73"></a> cnt1++;
|
||
|
<a name="l74"></a> }
|
||
|
<a name="l75"></a> tmpb=tmpb->next;
|
||
|
<a name="l76"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l77"></a>
|
||
|
<a name="l78"></a> tmpt=t_head.next;
|
||
|
<a name="l79"></a> cnt2=0;
|
||
|
<a name="l80"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=&t_head) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l81"></a> tmpt->b.credit_idx =StrFileAdd(tmpt->b.credit,&num,table);
|
||
|
<a name="l82"></a> tmpt->b.debit_idx =StrFileAdd(tmpt->b.debit,&num,table);
|
||
|
<a name="l83"></a> tmpt->b.desc_idx =StrFileAdd(tmpt->b.desc,&num,table);
|
||
|
<a name="l84"></a> cnt2++;
|
||
|
<a name="l85"></a> tmpt=tmpt->next;
|
||
|
<a name="l86"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l87"></a> StrFileWrite(bgt_string_file,table);
|
||
|
<a name="l88"></a> StrFileDel(table);
|
||
|
<a name="l89"></a>
|
||
|
<a name="l90"></a> size=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0>)*2+cnt1*BE_SIZE+cnt2*(BT_SIZE+BE_SIZE);
|
||
|
<a name="l91"></a> buf=ptr=</span><span class=cF5>MAlloc</span><span class=cF0>(size);
|
||
|
<a name="l92"></a>
|
||
|
<a name="l93"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(ptr,&cnt1,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l94"></a> ptr+=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0>);
|
||
|
<a name="l95"></a> tmpb=b_head.next;
|
||
|
<a name="l96"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&b_head) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l97"></a> </span><span class=cF1>if</span><span class=cF0> (tmpb->type!=BE_TEMPLATE_COPY) {
|
||
|
<a name="l98"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(ptr,&tmpb-></span><span class=cF1>start</span><span class=cF0>,BE_SIZE);
|
||
|
<a name="l99"></a> ptr+=BE_SIZE;
|
||
|
<a name="l100"></a> }
|
||
|
<a name="l101"></a> tmpb=tmpb->next;
|
||
|
<a name="l102"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l103"></a>
|
||
|
<a name="l104"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(ptr,&cnt2,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>I64</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l105"></a> ptr+=</span><span class=cF1>sizeof</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0>);
|
||
|
<a name="l106"></a> tmpt=t_head.next;
|
||
|
<a name="l107"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=&t_head) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l108"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(ptr,&tmpt-></span><span class=cF1>start</span><span class=cF0>,BT_SIZE);
|
||
|
<a name="l109"></a> ptr+=BT_SIZE;
|
||
|
<a name="l110"></a> </span><span class=cF5>MemCpy</span><span class=cF0>(ptr,&tmpt->b.</span><span class=cF1>start</span><span class=cF0>,BE_SIZE);
|
||
|
<a name="l111"></a> ptr+=BE_SIZE;
|
||
|
<a name="l112"></a> tmpt=tmpt->next;
|
||
|
<a name="l113"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l114"></a>
|
||
|
<a name="l115"></a> </span><span class=cF5>FileWrite</span><span class=cF0>(bgt_data_file,buf,size);
|
||
|
<a name="l116"></a> </span><span class=cF5>Free</span><span class=cF0>(buf);
|
||
|
<a name="l117"></a>}
|
||
|
<a name="l118"></a>
|
||
|
<a name="l119"></a></span><span class=cF1>U0</span><span class=cF0> BgtDel()
|
||
|
<a name="l120"></a>{
|
||
|
<a name="l121"></a> CBgtEntry *tmpb,*tmpb1;
|
||
|
<a name="l122"></a> CBgtTemplate *tmpt,*tmpt1;
|
||
|
<a name="l123"></a> tmpb=b_head.next;
|
||
|
<a name="l124"></a> </span><span class=cF1>while</span><span class=cF0> (tmpb!=&b_head) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l125"></a> tmpb1=tmpb->next;
|
||
|
<a name="l126"></a> BgtEntryDel2(tmpb);
|
||
|
<a name="l127"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpb);
|
||
|
<a name="l128"></a> tmpb=tmpb1;
|
||
|
<a name="l129"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l130"></a> tmpt=t_head.next;
|
||
|
<a name="l131"></a> </span><span class=cF1>while</span><span class=cF0> (tmpt!=&t_head) </span><span class=cF7>{</span><span class=cF0>
|
||
|
<a name="l132"></a> tmpt1=tmpt->next;
|
||
|
<a name="l133"></a> BgtEntryDel2(&tmpt->b);
|
||
|
<a name="l134"></a> </span><span class=cF5>Free</span><span class=cF0>(tmpt);
|
||
|
<a name="l135"></a> tmpt=tmpt1;
|
||
|
<a name="l136"></a> </span><span class=cF7>}</span><span class=cF0>
|
||
|
<a name="l137"></a> StrFileDel(accts_table);
|
||
|
<a name="l138"></a> accts_table=</span><span class=cF3>NULL</span><span class=cF0>;
|
||
|
<a name="l139"></a> accts_table_strs=0;
|
||
|
<a name="l140"></a>}
|
||
|
</span></pre></body>
|
||
|
</html>
|