2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2002-01-07 19:16:03 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Announce new files and FileFind
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2004-01-25 10:57:35 +00:00
|
|
|
* Copyright (C) 1997-2004
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS 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, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2002-01-07 19:16:03 +00:00
|
|
|
#include "../lib/users.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbsedb.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "../lib/msg.h"
|
|
|
|
#include "../lib/msgtext.h"
|
2002-03-31 13:09:23 +00:00
|
|
|
#include "../lib/diesel.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "grlist.h"
|
|
|
|
#include "msgutil.h"
|
|
|
|
#include "announce.h"
|
|
|
|
|
|
|
|
|
2002-06-19 20:31:35 +00:00
|
|
|
extern int do_quiet; /* Suppress screen output */
|
2001-08-17 05:46:24 +00:00
|
|
|
struct _filerecord T_File; /* Internal announce record */
|
|
|
|
int TotalFiles; /* Total announced files */
|
|
|
|
unsigned long TotalSize; /* Total size in KBytes. */
|
|
|
|
int MsgCount; /* Message counter */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a file whos data is in T_File to the toberep.data file.
|
|
|
|
*/
|
|
|
|
int Add_ToBeRep(void);
|
|
|
|
int Add_ToBeRep()
|
|
|
|
{
|
2002-03-31 13:09:23 +00:00
|
|
|
char *fname;
|
|
|
|
struct _filerecord Temp;
|
|
|
|
FILE *tbr;
|
|
|
|
int Found = FALSE;
|
|
|
|
|
|
|
|
fname = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(fname, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((tbr = fopen(fname, "a+")) == NULL) {
|
|
|
|
WriteError("$Can't create %s", fname);
|
2001-08-17 05:46:24 +00:00
|
|
|
free(fname);
|
2002-03-31 13:09:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
free(fname);
|
|
|
|
|
|
|
|
fseek(tbr, 0, SEEK_SET);
|
|
|
|
while (fread(&Temp, sizeof(Temp), 1, tbr) == 1) {
|
|
|
|
if ((strcmp(Temp.Name, T_File.Name) == 0) && (Temp.Fdate = T_File.Fdate))
|
|
|
|
Found = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Found) {
|
|
|
|
Syslog('!', "File %s already in toberep.data", T_File.Name);
|
2001-08-17 05:46:24 +00:00
|
|
|
fclose(tbr);
|
2002-03-31 13:09:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
fwrite(&T_File, sizeof(T_File), 1, tbr);
|
|
|
|
fclose(tbr);
|
|
|
|
return TRUE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for uploads, these are files in the files database with
|
|
|
|
* the announced flag not yet set.
|
|
|
|
*/
|
|
|
|
void Uploads(void);
|
|
|
|
void Uploads()
|
|
|
|
{
|
2002-03-31 13:09:23 +00:00
|
|
|
FILE *pAreas, *pFile;
|
|
|
|
char *sAreas, *fAreas;
|
|
|
|
int Count = 0, i = 0, j, k;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
sAreas = calloc(PATH_MAX, sizeof(char));
|
|
|
|
fAreas = calloc(PATH_MAX, sizeof(char));
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
Syslog('+', "Checking for uploads");
|
|
|
|
IsDoing("Check uploads");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!do_quiet) {
|
|
|
|
colour(3, 0);
|
|
|
|
printf(" Checking uploads...\n");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
sprintf(sAreas, "%s/etc/fareas.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((pAreas = fopen(sAreas, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", sAreas);
|
|
|
|
free(sAreas);
|
|
|
|
free(fAreas);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fread(&areahdr, sizeof(areahdr), 1, pAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
i++;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (CFG.slow_util && do_quiet)
|
2004-01-25 10:57:35 +00:00
|
|
|
msleep(1);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if ((area.Available) && strlen(area.NewGroup)) {
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!do_quiet) {
|
|
|
|
printf("\r %4d => %-44s", i, area.Name);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);
|
|
|
|
if ((pFile = fopen(fAreas, "r+")) != NULL) {
|
|
|
|
|
|
|
|
while (fread(&file, sizeof(file), 1, pFile) == 1) {
|
|
|
|
Nopper();
|
|
|
|
if (!file.Announced) {
|
|
|
|
Syslog('m', " %d %s", i, file.Name);
|
|
|
|
memset(&T_File, 0, sizeof(T_File));
|
|
|
|
sprintf(T_File.Echo, "AREA %d", i);
|
|
|
|
sprintf(T_File.Group, "%s", area.NewGroup);
|
|
|
|
sprintf(T_File.Comment, "%s", area.Name);
|
|
|
|
sprintf(T_File.Name, "%s", file.Name);
|
2004-02-17 19:49:15 +00:00
|
|
|
sprintf(T_File.LName, "%s", file.LName);
|
2002-03-31 13:09:23 +00:00
|
|
|
T_File.Size = file.Size;
|
|
|
|
T_File.SizeKb = file.Size / 1024;
|
|
|
|
T_File.Fdate = file.FileDate;
|
|
|
|
sprintf(T_File.Crc, "%08lx", file.Crc32);
|
|
|
|
sprintf(T_File.Desc, "%s %s %s %s", file.Desc[0], file.Desc[1], file.Desc[2], file.Desc[3]);
|
|
|
|
k = 0;
|
|
|
|
for (j = 0; j < 25; j++) {
|
|
|
|
if (strlen(file.Desc[j])) {
|
|
|
|
sprintf(T_File.LDesc[k], "%s", file.Desc[j]);
|
|
|
|
T_File.LDesc[k][49] = '\0';
|
|
|
|
k++;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
T_File.TotLdesc = k;
|
|
|
|
T_File.Cost = file.Cost;
|
|
|
|
T_File.Announce = TRUE;
|
|
|
|
if (Add_ToBeRep())
|
|
|
|
Count++;
|
|
|
|
/*
|
|
|
|
* Mark file is announced.
|
|
|
|
*/
|
|
|
|
file.Announced = TRUE;
|
|
|
|
fseek(pFile, - sizeof(file), SEEK_CUR);
|
|
|
|
fwrite(&file, sizeof(file), 1, pFile);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
fclose(pFile);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!do_quiet) {
|
|
|
|
printf("\r \r");
|
2001-08-17 05:46:24 +00:00
|
|
|
if (Count)
|
2002-03-31 13:09:23 +00:00
|
|
|
printf(" %d new uploads\n", Count);
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Count)
|
|
|
|
Syslog('+', "%d new uploads", Count);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
fclose(pAreas);
|
|
|
|
free(sAreas);
|
|
|
|
free(fAreas);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
long StartMsg(void);
|
|
|
|
long StartMsg(void)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!Msg_Open(newfiles.Area))
|
|
|
|
return -1;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!Msg_Lock(30L)) {
|
|
|
|
Msg_Close();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
Msg_New();
|
|
|
|
|
|
|
|
CountPosted(newfiles.Area);
|
|
|
|
|
|
|
|
sprintf(Msg.From, "%s", newfiles.From);
|
|
|
|
sprintf(Msg.To, "%s", newfiles.Too);
|
|
|
|
if (MsgCount == 1) {
|
|
|
|
sprintf(Msg.Subject, "%s", newfiles.Subject);
|
|
|
|
TotalSize = TotalFiles = 0;
|
|
|
|
} else
|
|
|
|
sprintf(Msg.Subject, "%s #%d", newfiles.Subject, MsgCount);
|
|
|
|
sprintf(Msg.FromAddress, "%s", aka2str(newfiles.UseAka));
|
|
|
|
Msg.Written = time(NULL);
|
|
|
|
Msg.Arrived = time(NULL);
|
|
|
|
Msg.Local = TRUE;
|
|
|
|
Msg.Echomail = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start message text including kludges
|
|
|
|
*/
|
|
|
|
Msg_Id(newfiles.UseAka);
|
|
|
|
Msg_Pid();
|
|
|
|
return Msg_Top(newfiles.Template, newfiles.Language, newfiles.UseAka);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
void FinishMsg(int, long);
|
|
|
|
void FinishMsg(int Final, long filepos)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 13:09:23 +00:00
|
|
|
char *temp;
|
|
|
|
FILE *fp, *fi;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
if (Final && ((fi = OpenMacro(newfiles.Template, newfiles.Language, FALSE)) != NULL)) {
|
2002-04-01 19:06:09 +00:00
|
|
|
/*
|
|
|
|
* Message footer
|
|
|
|
*/
|
|
|
|
MacroVars("CD", "dd", TotalFiles, TotalSize);
|
|
|
|
fseek(fi, filepos, SEEK_SET);
|
|
|
|
Msg_Macro(fi);
|
|
|
|
fclose(fi);
|
|
|
|
MacroClear();
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (strlen(newfiles.Origin))
|
|
|
|
Msg_Bot(newfiles.UseAka, newfiles.Origin, newfiles.Template);
|
|
|
|
else
|
|
|
|
Msg_Bot(newfiles.UseAka, CFG.origin, newfiles.Template);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
Msg_AddMsg();
|
|
|
|
Msg_UnLock();
|
|
|
|
Syslog('+', "Posted message %ld, %d bytes", Msg.Id, Msg.Size);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
sprintf(temp, "%s/tmp/echomail.jam", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "a")) != NULL) {
|
|
|
|
fprintf(fp, "%s %lu\n", newfiles.Area, Msg.Id);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
Msg_Close();
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-04-01 19:06:09 +00:00
|
|
|
/*
|
|
|
|
* Report one group block of new files.
|
|
|
|
*/
|
2002-03-31 13:09:23 +00:00
|
|
|
long Report(gr_list *, long);
|
|
|
|
long Report(gr_list *ta, long filepos)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2002-03-31 13:09:23 +00:00
|
|
|
FILE *fp, *fi;
|
|
|
|
char *temp, *line;
|
|
|
|
int i, Total = 0;
|
|
|
|
unsigned long Size = 0;
|
|
|
|
long filepos1 = 0, filepos2, filepos3 = 0, finalpos = 0;
|
2002-05-13 19:35:05 +00:00
|
|
|
time_t ftime;
|
2002-03-31 13:09:23 +00:00
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-05-12 21:28:13 +00:00
|
|
|
MacroVars("GJZ", "ssd", "", "", 0);
|
|
|
|
MacroVars("slbkdt", "ssddss", "", "", 0, 0, "", "");
|
|
|
|
MacroVars("ABZ", "ddd", 0, 0, 0);
|
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
|
|
|
|
if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group)))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-04-10 20:29:57 +00:00
|
|
|
if ((fi = OpenMacro(newfiles.Template, newfiles.Language, FALSE)) != NULL) {
|
2002-04-01 19:06:09 +00:00
|
|
|
/*
|
|
|
|
* Area block header
|
|
|
|
*/
|
2002-03-31 15:04:34 +00:00
|
|
|
MacroVars("GJZ", "ssd", T_File.Echo, T_File.Comment, 0);
|
2002-03-31 13:09:23 +00:00
|
|
|
fseek(fi, filepos, SEEK_SET);
|
|
|
|
Msg_Macro(fi);
|
|
|
|
filepos1 = ftell(fi);
|
|
|
|
} else {
|
2002-04-01 19:06:09 +00:00
|
|
|
free(temp);
|
|
|
|
return 0;
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fseek(fp, 0, SEEK_SET);
|
|
|
|
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
|
|
|
|
if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group))) {
|
|
|
|
|
|
|
|
if (CFG.slow_util && do_quiet)
|
2004-01-25 10:57:35 +00:00
|
|
|
msleep(1);
|
2002-03-31 13:09:23 +00:00
|
|
|
|
2002-04-01 19:06:09 +00:00
|
|
|
/*
|
|
|
|
* Report one newfile, first line.
|
|
|
|
*/
|
|
|
|
fseek(fi, filepos1, SEEK_SET);
|
2002-05-13 19:35:05 +00:00
|
|
|
ftime = T_File.Fdate;
|
2002-05-18 13:49:55 +00:00
|
|
|
MacroVars("sl", "ss", T_File.Name, T_File.LName);
|
|
|
|
MacroVars("bk", "dd", T_File.Size, T_File.SizeKb);
|
|
|
|
MacroVars("dt", "ss", rfcdate(ftime), To_Low(T_File.LDesc[0],newfiles.HiAscii));
|
2002-04-01 19:06:09 +00:00
|
|
|
Msg_Macro(fi);
|
|
|
|
filepos2 = ftell(fi);
|
2002-05-18 13:49:55 +00:00
|
|
|
|
2002-04-01 19:06:09 +00:00
|
|
|
/*
|
|
|
|
* Extra description lines follow
|
|
|
|
*/
|
|
|
|
for (i = 1; i < 24; i++) {
|
|
|
|
MacroVars("t", "s", To_Low(T_File.LDesc[i],newfiles.HiAscii));
|
|
|
|
fseek(fi, filepos2, SEEK_SET);
|
|
|
|
if (strlen(T_File.LDesc[i])) {
|
|
|
|
Msg_Macro(fi);
|
|
|
|
} else {
|
2002-05-12 21:28:13 +00:00
|
|
|
line = calloc(MAXSTR, sizeof(char));
|
|
|
|
while ((fgets(line, MAXSTR-2, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {}
|
2002-04-01 19:06:09 +00:00
|
|
|
free(line);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-04-01 19:06:09 +00:00
|
|
|
filepos3 = ftell(fi);
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
Total++;
|
|
|
|
Size += T_File.SizeKb;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-04-01 19:06:09 +00:00
|
|
|
/*
|
|
|
|
* Area block footer
|
|
|
|
*/
|
|
|
|
if (Msg.Size > (CFG.new_split * 1024))
|
|
|
|
MacroVars("ABZ", "ddd", Total, Size, 1);
|
|
|
|
else
|
|
|
|
MacroVars("ABZ", "ddd", Total, Size, 0);
|
|
|
|
fseek(fi, filepos3, SEEK_SET);
|
|
|
|
Msg_Macro(fi);
|
|
|
|
finalpos = ftell(fi);
|
2002-03-31 13:09:23 +00:00
|
|
|
fclose(fp);
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
/*
|
2002-04-01 19:06:09 +00:00
|
|
|
* Split messages if too big.
|
2002-03-31 13:09:23 +00:00
|
|
|
*/
|
|
|
|
if (Msg.Size > (CFG.new_split * 1024)) {
|
|
|
|
MsgCount++;
|
|
|
|
FinishMsg(FALSE, finalpos);
|
|
|
|
StartMsg();
|
|
|
|
}
|
|
|
|
|
|
|
|
TotalFiles += Total;
|
|
|
|
TotalSize += Size;
|
|
|
|
|
|
|
|
if (fi != NULL) {
|
|
|
|
fclose(fi);
|
|
|
|
}
|
|
|
|
return finalpos;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Announce()
|
|
|
|
{
|
2002-03-31 13:09:23 +00:00
|
|
|
gr_list *fgr = NULL, *tmp;
|
|
|
|
char *temp;
|
|
|
|
FILE *fp;
|
|
|
|
int Count = 0, rc = FALSE;
|
|
|
|
long filepos, filepos1, filepos2;
|
|
|
|
char group[13];
|
|
|
|
int i, groups, any;
|
|
|
|
|
|
|
|
if (!do_quiet) {
|
|
|
|
colour(3, 0);
|
|
|
|
printf("Announce new files\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
Uploads();
|
|
|
|
IsDoing("Announce files");
|
|
|
|
|
2002-05-12 21:28:13 +00:00
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2002-03-31 13:09:23 +00:00
|
|
|
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
|
|
|
Syslog('+', "No new files to announce");
|
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
if (!do_quiet) {
|
2002-03-31 13:09:23 +00:00
|
|
|
printf(" No new files.\n");
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!do_quiet)
|
|
|
|
printf(" Preparing reports...\n");
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
|
|
|
|
if (T_File.Announce) {
|
|
|
|
fill_grlist(&fgr, T_File.Group, T_File.Echo);
|
|
|
|
Count++;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
fclose(fp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (Count == 0) {
|
|
|
|
unlink(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
if (!do_quiet)
|
2002-03-31 13:09:23 +00:00
|
|
|
printf(" No new files.\n");
|
|
|
|
Syslog('+', "No new files to announce");
|
|
|
|
free(temp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!do_quiet)
|
|
|
|
printf(" %d new files found\n", Count);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
sort_grlist(&fgr);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
/*
|
|
|
|
* At this point we have a sorted list of groups with a counter
|
|
|
|
* indicating howmany files to report in each group.
|
|
|
|
*/
|
|
|
|
sprintf(temp, "%s/etc/newfiles.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", temp);
|
|
|
|
if (!do_quiet)
|
|
|
|
printf(" No newfile reports defined\n");
|
|
|
|
free(temp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
fread(&newfileshdr, sizeof(newfileshdr), 1, fp);
|
|
|
|
groups = newfileshdr.grpsize / 13;
|
|
|
|
|
|
|
|
while (fread(&newfiles, newfileshdr.recsize, 1, fp) == 1) {
|
|
|
|
if (newfiles.Active) {
|
|
|
|
filepos = ftell(fp);
|
|
|
|
if (!do_quiet)
|
|
|
|
printf(" %s\n", newfiles.Comment);
|
|
|
|
any = FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < groups; i++) {
|
|
|
|
fread(&group, 13, 1, fp);
|
|
|
|
for (tmp = fgr; tmp; tmp = tmp->next)
|
|
|
|
if (strcmp(tmp->group, group) == 0)
|
|
|
|
any = TRUE;
|
|
|
|
}
|
|
|
|
if (any) {
|
|
|
|
fseek(fp, filepos, SEEK_SET);
|
|
|
|
rc = TRUE;
|
|
|
|
Syslog('+', "Create report: %s", newfiles.Comment);
|
|
|
|
MsgCount = 1;
|
|
|
|
if ((filepos1 = StartMsg()) != -1) {
|
|
|
|
filepos2 = 0;
|
|
|
|
while (fread(&group, 13, 1, fp) == 1) {
|
2002-05-12 21:28:13 +00:00
|
|
|
for (tmp = fgr; tmp; tmp = tmp->next) {
|
2002-03-31 13:09:23 +00:00
|
|
|
if (!strcmp(tmp->group, group)) {
|
|
|
|
filepos2 = Report(tmp, filepos1);
|
|
|
|
}
|
2002-05-12 21:28:13 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
}
|
|
|
|
FinishMsg(TRUE, filepos2);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-03-31 13:09:23 +00:00
|
|
|
} else {
|
|
|
|
if (!do_quiet)
|
|
|
|
printf(" No matching groups\n");
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
fseek(fp, filepos, SEEK_SET);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
fseek(fp, newfileshdr.grpsize, SEEK_CUR);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
tidy_grlist(&fgr);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
if (rc) {
|
|
|
|
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
|
|
|
|
unlink(temp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-03-31 13:09:23 +00:00
|
|
|
free(temp);
|
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|