|
|
1.1 root 1: /* getstats.c */
2:
3: /* Synchronet C-export statistics retrieval functions */
4:
1.1.1.2 ! root 5: /* $Id: getstats.c,v 1.3 2010/03/06 00:13:04 rswindell Exp $ */
1.1 root 6:
7: /****************************************************************************
8: * @format.tab-size 4 (Plain Text/Source Code File Header) *
9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
10: * *
1.1.1.2 ! root 11: * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html *
1.1 root 12: * *
13: * This program is free software; you can redistribute it and/or *
14: * modify it under the terms of the GNU General Public License *
15: * as published by the Free Software Foundation; either version 2 *
16: * of the License, or (at your option) any later version. *
17: * See the GNU General Public License for more details: gpl.txt or *
18: * http://www.fsf.org/copyleft/gpl.html *
19: * *
20: * Anonymous FTP access to the most recent released source is available at *
21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
22: * *
23: * Anonymous CVS access to the development source and modification history *
24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: *
25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login *
26: * (just hit return, no password is necessary) *
27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src *
28: * *
29: * For Synchronet coding style and modification guidelines, see *
30: * http://www.synchro.net/source.html *
31: * *
32: * You are encouraged to submit any modifications (preferably in Unix diff *
33: * format) via e-mail to [email protected] *
34: * *
35: * Note: If this box doesn't appear square, then you need to fix your tabs. *
36: ****************************************************************************/
37:
38: #include "sbbs.h"
39:
40: /****************************************************************************/
41: /* Reads data from dsts.dab into stats structure */
42: /* If node is zero, reads from ctrl\dsts.dab, otherwise from each node */
43: /****************************************************************************/
44: BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats)
45: {
46: char str[MAX_PATH+1];
47: int file;
48:
49: sprintf(str,"%sdsts.dab",node ? cfg->node_path[node-1] : cfg->ctrl_dir);
50: if((file=nopen(str,O_RDONLY))==-1) {
51: return(FALSE);
52: }
53: lseek(file,4L,SEEK_SET); /* Skip update time/date */
1.1.1.2 ! root 54: /* TODO: Direct read of unpacked struct */
1.1 root 55: read(file,stats,sizeof(stats_t));
56: close(file);
57: return(TRUE);
58: }
59:
60: /****************************************************************************/
61: /* Returns the number of files in the directory 'dirnum' */
62: /****************************************************************************/
63: long DLLCALL getfiles(scfg_t* cfg, uint dirnum)
64: {
65: char str[256];
66: long l;
67:
68: if(dirnum>=cfg->total_dirs) /* out of range */
69: return(0);
70: sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir, cfg->dir[dirnum]->code);
1.1.1.2 ! root 71: l=(long)flength(str);
1.1 root 72: if(l>0L)
73: return(l/F_IXBSIZE);
74: return(0);
75: }
76:
77: /****************************************************************************/
78: /* Returns total number of posts in a sub-board */
79: /****************************************************************************/
80: ulong DLLCALL getposts(scfg_t* cfg, uint subnum)
81: {
82: char str[128];
83: ulong l;
84:
85: sprintf(str,"%s%s.sid",cfg->sub[subnum]->data_dir,cfg->sub[subnum]->code);
1.1.1.2 ! root 86: l=(long)flength(str);
1.1 root 87: if((long)l==-1)
88: return(0);
89: return(l/sizeof(idxrec_t));
90: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.