Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit f2b5a593 authored by rswindell's avatar rswindell

Moved getstats(), getposts(), and getfiles() to new file: getstats.c.

parent 74e42bfe
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -105,23 +105,6 @@ uint sbbs_t::finduser(char *instr)
return(0);
}
/****************************************************************************/
/* Returns the number of files in the directory 'dirnum' */
/****************************************************************************/
long DLLCALL getfiles(scfg_t* cfg, uint dirnum)
{
char str[256];
long l;
if(dirnum>=cfg->total_dirs) /* out of range */
return(0);
sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir, cfg->dir[dirnum]->code);
l=flength(str);
if(l>0L)
return(l/F_IXBSIZE);
return(0);
}
/****************************************************************************/
/* Returns the number of user transfers in XFER.IXT for either a dest user */
/* source user, or filename. */
......
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -316,22 +316,6 @@ void sbbs_t::msgtotxt(smbmsg_t* msg, char *str, int header, int tails)
fclose(out);
}
/****************************************************************************/
/* Returns total number of posts in a sub-board */
/****************************************************************************/
ulong DLLCALL getposts(scfg_t* cfg, uint subnum)
{
char str[128];
ulong l;
sprintf(str,"%s%s.sid",cfg->sub[subnum]->data_dir,cfg->sub[subnum]->code);
l=flength(str);
if((long)l==-1)
return(0);
return(l/sizeof(idxrec_t));
}
/****************************************************************************/
/* Returns message number posted at or after time */
/****************************************************************************/
......
/* getstats.c */
/* Synchronet C-export statistics retrieval functions */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2003 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#include "sbbs.h"
/****************************************************************************/
/* Reads data from dsts.dab into stats structure */
/* If node is zero, reads from ctrl\dsts.dab, otherwise from each node */
/****************************************************************************/
BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats)
{
char str[MAX_PATH+1];
int file;
sprintf(str,"%sdsts.dab",node ? cfg->node_path[node-1] : cfg->ctrl_dir);
if((file=nopen(str,O_RDONLY))==-1) {
return(FALSE);
}
lseek(file,4L,SEEK_SET); /* Skip update time/date */
read(file,stats,sizeof(stats_t));
close(file);
return(TRUE);
}
/****************************************************************************/
/* Returns the number of files in the directory 'dirnum' */
/****************************************************************************/
long DLLCALL getfiles(scfg_t* cfg, uint dirnum)
{
char str[256];
long l;
if(dirnum>=cfg->total_dirs) /* out of range */
return(0);
sprintf(str,"%s%s.ixb",cfg->dir[dirnum]->data_dir, cfg->dir[dirnum]->code);
l=flength(str);
if(l>0L)
return(l/F_IXBSIZE);
return(0);
}
/****************************************************************************/
/* Returns total number of posts in a sub-board */
/****************************************************************************/
ulong DLLCALL getposts(scfg_t* cfg, uint subnum)
{
char str[128];
ulong l;
sprintf(str,"%s%s.sid",cfg->sub[subnum]->data_dir,cfg->sub[subnum]->code);
l=flength(str);
if((long)l==-1)
return(0);
return(l/sizeof(idxrec_t));
}
......@@ -2639,27 +2639,6 @@ int sbbs_t::mv(char *src, char *dest, char copy)
return(0);
}
/****************************************************************************/
/* Reads data from dsts.dab into stats structure */
/* If node is zero, reads from ctrl\dsts.dab, otherwise from each node */
/****************************************************************************/
BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats)
{
char str[MAX_PATH+1];
int file;
sprintf(str,"%sdsts.dab",node ? cfg->node_path[node-1] : cfg->ctrl_dir);
if((file=nopen(str,O_RDONLY))==-1) {
// errormsg(WHERE,ERR_OPEN,str,O_RDONLY);
return(FALSE);
}
lseek(file,4L,SEEK_SET); /* Skip update time/date */
read(file,stats,sizeof(stats_t));
close(file);
return(TRUE);
}
void sbbs_t::hangup(void)
{
if(client_socket!=INVALID_SOCKET) {
......
......@@ -38,6 +38,7 @@ OBJS = $(LIBODIR)$(SLASH)ansiterm.$(OFILE)\
$(LIBODIR)$(SLASH)getmail.$(OFILE)\
$(LIBODIR)$(SLASH)getmsg.$(OFILE)\
$(LIBODIR)$(SLASH)getnode.$(OFILE)\
$(LIBODIR)$(SLASH)getstats.$(OFILE)\
$(LIBODIR)$(SLASH)getstr.$(OFILE)\
$(LIBODIR)$(SLASH)ini_file.$(OFILE)\
$(LIBODIR)$(SLASH)inkey.$(OFILE)\
......
......@@ -230,6 +230,10 @@ SOURCE=.\getnode.cpp
# End Source File
# Begin Source File
SOURCE=.\getstats.c
# End Source File
# Begin Source File
SOURCE=.\getstr.cpp
# End Source File
# Begin Source File
......
......@@ -747,8 +747,10 @@ public:
extern "C" {
#endif
/* main.cpp */
/* getstats.c */
DLLEXPORT BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats);
DLLEXPORT ulong DLLCALL getposts(scfg_t* cfg, uint subnum);
DLLEXPORT long DLLCALL getfiles(scfg_t* cfg, uint dirnum);
/* getmail.c */
DLLEXPORT int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent);
......@@ -775,8 +777,6 @@ extern "C" {
DLLEXPORT char * DLLCALL unpadfname(char *filename, char *str);
DLLEXPORT BOOL DLLCALL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname);
DLLEXPORT ulong DLLCALL getposts(scfg_t* cfg, uint subnum);
DLLEXPORT long DLLCALL getfiles(scfg_t* cfg, uint dirnum);
DLLEXPORT int DLLCALL update_uldate(scfg_t* cfg, file_t* f);
/* str_util.c */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment