|
|
1.1 root 1: /* Synchronet Control Panel (GUI Borland C++ Builder Project for Win32) */
2:
3: /* $Id: StatsLogFormUnit.cpp,v 1.3 2005/09/20 03:40:18 deuce Exp $ */
4:
5: /****************************************************************************
6: * @format.tab-size 4 (Plain Text/Source Code File Header) *
7: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
8: * *
9: * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html *
10: * *
11: * This program is free software; you can redistribute it and/or *
12: * modify it under the terms of the GNU General Public License *
13: * as published by the Free Software Foundation; either version 2 *
14: * of the License, or (at your option) any later version. *
15: * See the GNU General Public License for more details: gpl.txt or *
16: * http://www.fsf.org/copyleft/gpl.html *
17: * *
18: * Anonymous FTP access to the most recent released source is available at *
19: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
20: * *
21: * Anonymous CVS access to the development source and modification history *
22: * is available at cvs.synchro.net:/cvsroot/sbbs, example: *
23: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login *
24: * (just hit return, no password is necessary) *
25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src *
26: * *
27: * For Synchronet coding style and modification guidelines, see *
28: * http://www.synchro.net/source.html *
29: * *
30: * You are encouraged to submit any modifications (preferably in Unix diff *
31: * format) via e-mail to [email protected] *
32: * *
33: * Note: If this box doesn't appear square, then you need to fix your tabs. *
34: ****************************************************************************/
35:
36: //---------------------------------------------------------------------------
37: #include <vcl.h>
38: #pragma hdrstop
39:
40: #include <io.h> // filelength()
41: #include <stdio.h> // sprintf()
42: #include <time.h> // time_t
43: #include <fcntl.h> // O_RDONLY
44: #include <share.h>
45: #include "MainFormUnit.h"
46: #include "StatsLogFormUnit.h"
47: //---------------------------------------------------------------------------
48: #pragma package(smart_init)
49: #pragma resource "*.dfm"
50: TStatsLogForm *StatsLogForm;
51: //---------------------------------------------------------------------------
52: __fastcall TStatsLogForm::TStatsLogForm(TComponent* Owner)
53: : TForm(Owner)
54: {
55: }
56: //---------------------------------------------------------------------------
57: void __fastcall TStatsLogForm::FormShow(TObject *Sender)
58: {
59: char str[256],path[256],*p;
60: BYTE *buf;
61: int i,file;
62: time_t timestamp;
63: struct tm* tm;
64: long l;
65: DWORD length,
66: logons,
67: timeon,
68: posts,
69: emails,
70: fbacks,
71: ulb,
72: uls,
73: dlb,
74: dls;
75:
76: sprintf(path,"%sCSTS.DAB",MainForm->global.ctrl_dir);
77: if((file=_sopen(path,O_RDONLY|O_BINARY,SH_DENYNO))==-1) {
78: sprintf(str,"!Error opening %s",path);
79: Log->Lines->Add(AnsiString(str));
80: return;
81: }
82: length=filelength(file);
83: if(length<40) {
84: close(file);
85: return;
86: }
87: if((buf=(char *)malloc(length))==NULL) {
88: close(file);
89: sprintf(str,"!Error allocating %lu bytes",length);
90: Log->Lines->Add(AnsiString(str));
91: return;
92: }
93: read(file,buf,length);
94: close(file);
95: l=length-4;
96: while(l>-1L) {
97: fbacks=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
98: |((long)buf[l+3]<<24);
99: l-=4;
100: emails=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
101: |((long)buf[l+3]<<24);
102: l-=4;
103: posts=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
104: |((long)buf[l+3]<<24);
105: l-=4;
106: dlb=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
107: |((long)buf[l+3]<<24);
108: l-=4;
109: dls=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
110: |((long)buf[l+3]<<24);
111: l-=4;
112: ulb=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
113: |((long)buf[l+3]<<24);
114: l-=4;
115: uls=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
116: |((long)buf[l+3]<<24);
117: l-=4;
118: timeon=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
119: |((long)buf[l+3]<<24);
120: l-=4;
121: logons=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
122: |((long)buf[l+3]<<24);
123: l-=4;
124: timestamp=buf[l]|((long)buf[l+1]<<8)|((long)buf[l+2]<<16)
125: |((long)buf[l+3]<<24);
126: l-=4;
127: timestamp-=(24*60*60); /* 1 day less than stamp */
128: tm=localtime(×tamp);
129: sprintf(str,"%2.2d/%2.2d/%2.2d T:%5lu L:%3lu P:%3lu "
130: "E:%3lu F:%3lu U:%6luk %3lu D:%6luk %3lu"
131: ,tm->tm_mon+1,tm->tm_mday,tm->tm_year%100,timeon,logons,posts,emails
132: ,fbacks,ulb/1024,uls,dlb/1024,dls);
133: Log->Lines->Add(AnsiString(str));
134: }
135: free(buf);
136: }
137: //---------------------------------------------------------------------------
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.