Added template processing for newfiles

This commit is contained in:
Michiel Broek 2002-03-31 13:09:23 +00:00
parent faea9ec83a
commit deff3bc1d6
17 changed files with 945 additions and 798 deletions

View File

@ -4692,11 +4692,18 @@ v0.33.20 10-Feb-2002
The mbfido news functions doesn't abort anymore when a
newsgroup didn't exist.
For points in echomail no seen-by entry is added.
The AreaMgr and FileMgr responses and notify messages now use
the diesel macro language with fallback to hardcoded replies.
mball:
Will not crash anymore when it needs more then 10 minutes to
create the allfiles and newfiles lists.
mbaff:
The High-ascii table to translate to lowercase has now the
right values to translate the ansi graphics.
Now uses the template newfiles to create the reports.
mbtask:
Removed some debug logging.
Creates the semafore is_inet when the internet connections is
@ -4767,4 +4774,7 @@ v0.33.20 10-Feb-2002
The Makefile now selects the right little or big endian menu
files to install.
Rebuild the menus and txtfiles for the new external editor.
Added templates.tar. For the time of development they will be
installed destructive, ie. all private changes will be lost
with every install. Later this will be a normal install.

View File

@ -17,3 +17,39 @@ mbsebbs-0_33_18_final 02-Nov-2001 Version 0.33.18 released.
mbsebbs-0_33_19_current 02-Nov-2001 Start 0.33.19 current development.
mbsebbs-0_33_19_final 10-Feb-2002 Version 0.33.19 released.
mbsebbs-0_33_20_current 10-Feb-2002 Start 0.33.20 current development.
CVS usage.
This will only work for registered MBSE developers. Replace username with your
sourceforge's username. To initialize your account on the sourceforge cvs
server do:
ssh username@cvs.sourceforge.net
This command will fail but creates your homedirectory on the sourceforge cvs
server.
Set the following two variables (and add them to .profile):
export CVS_RSH=ssh
export CVSROOT=username@cvs.mbse.sourceforge.net:/cvsroot/mbse
Install the sources with the followin command:
cvs co mbsebbs
That will create the directory mbsebbs with all subdirectories. When you made
some changes you can commit these from within the directory mbsebbs with:
cvs ci -m "Description of your changes"
To get a fresh source with changes of other developers do:
cd mbsebbs
cvs update
Michiel.

View File

@ -3,7 +3,7 @@
include ../Makefile.global
OTHER = Makefile header.txt footer.txt menus-le.tar menus-be.tar txtfiles.tar
OTHER = Makefile header.txt footer.txt menus-le.tar menus-be.tar txtfiles.tar templates.tar
#####################################################################################
@ -29,6 +29,7 @@ install:
tar xfC txtfiles.tar ${PREFIX}/english/txtfiles ; \
echo "Installing default english txtfiles" ; \
fi
tar xfC templates.tar ${PREFIX}/english/macro
clean:
rm -f filelist Makefile.bak

View File

@ -7,7 +7,7 @@ This is a modified version of diesel language. Diesel is a interpreted
macro language, used in AutoCAD and released to public domain by AutoDesk.
Modified version by Redy Rodriguez, for use in mbsebbs. Original diesel
language can be found at http://www.fournilab.ch/diesel.
language can be found at http://www.fourmilab.ch/diesel.
This "Dumb Interpretively Executed String Expression Language" is the
kernel of a macro language you can customise by adding C code and

View File

@ -27,7 +27,7 @@ MSGBASE_HDRS = jam.h jammsg.h jamsys.h msg.h msgtext.h
MBINET_SRCS = nntp.c pop3.c smtp.c
MBINET_OBJS = nntp.o pop3.o smtp.o
MBINET_HDRS = mbinet.h
DIESEL_SRSC = diesel.c mbdiesel.c
DIESEL_SRCS = diesel.c mbdiesel.c
DIESEL_HDRS = diesel.h
DIESEL_OBJS = diesel.o mbdiesel.o
MEMWATCH_SRCS = memwatch.c
@ -168,6 +168,8 @@ msgtext.o: libs.h msgtext.h msg.h
nntp.o: libs.h structs.h users.h records.h clcomm.h mbinet.h
pop3.o: libs.h structs.h users.h records.h clcomm.h mbinet.h
smtp.o: libs.h structs.h users.h records.h clcomm.h mbinet.h
diesel.o: libs.h diesel.h
mbdiesel.o: libs.h structs.h users.h records.h clcomm.h diesel.h
memwatch.o: ../config.h ../config.h libs.h memwatch.h
ftscprod.o: libs.h structs.h common.h
# End of generated dependencies

View File

@ -764,16 +764,16 @@ Mfunc(f_edtime)
} pictab[] = {
/* Careful! These must be sorted by descending order of
picture string length. */
{"YYYY", "%02d", &year},
{"DD", "%02d", &mday},
{"HH", "%02d", &heure},
{"MM", "%02d", &min},
{"MO", "%02d", &tmon},
{"SS", "%02d", &sec},
{"YY", "%02d", &yearmod100},
{"D", "%d", &mday},
{"H", "%d", &heure},
{"M", "%d", &tmon}
{(char *)"YYYY", (char *)"%02d", &year},
{(char *)"DD", (char *)"%02d", &mday},
{(char *)"HH", (char *)"%02d", &heure},
{(char *)"MM", (char *)"%02d", &min},
{(char *)"MO", (char *)"%02d", &tmon},
{(char *)"SS", (char *)"%02d", &sec},
{(char *)"YY", (char *)"%02d", &yearmod100},
{(char *)"D", (char *)"%d", &mday},
{(char *)"H", (char *)"%d", &heure},
{(char *)"M", (char *)"%d", &tmon}
};
ArgCount(2, 2);
@ -833,59 +833,59 @@ Mfunc(f_edtime)
if (strncasecmp(pp, lComp(month)) == 0) {
static char *mois[] = {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
(char *)"January",
(char *)"February",
(char *)"March",
(char *)"April",
(char *)"May",
(char *)"June",
(char *)"July",
(char *)"August",
(char *)"September",
(char *)"October",
(char *)"November",
(char *)"December"
};
V strcat(output, mois[jd->tm_mon]);
pp += lcompl;
} else if (strncasecmp(pp, lComp(mon)) == 0) {
static char *mois[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
(char *)"Jan",
(char *)"Feb",
(char *)"Mar",
(char *)"Apr",
(char *)"May",
(char *)"Jun",
(char *)"Jul",
(char *)"Aug",
(char *)"Sep",
(char *)"Oct",
(char *)"Nov",
(char *)"Dec"
};
V strcat(output, mois[jd->tm_mon]);
pp += lcompl;
} else if (strncasecmp(pp, lComp(dddd)) == 0) {
static char *jour[] = {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
(char *)"Sunday",
(char *)"Monday",
(char *)"Tuesday",
(char *)"Wednesday",
(char *)"Thursday",
(char *)"Friday",
(char *)"Saturday"
};
V strcat(output, jour[jd->tm_wday]);
pp += lcompl;
} else if (strncasecmp(pp, lComp(ddd)) == 0) {
static char *jour[] = {
"Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat"
(char *)"Sun",
(char *)"Mon",
(char *)"Tue",
(char *)"Wed",
(char *)"Thu",
(char *)"Fri",
(char *)"Sat"
};
V strcat(output, jour[jd->tm_wday]);
pp += lcompl;
@ -1363,43 +1363,43 @@ Mfunc(f_xor)
/* Macro name/function table. */
static struct mfent mftab[] = {
{"+", f_plus},
{"-", f_minus},
{"*", f_times},
{"/", f_divide},
{"=", f_numeq},
{"<", f_numlt},
{">", f_numgt},
{"!=", f_numne},
{"<=", f_numle},
{">=", f_numge},
{"AND", f_and},
{"EQ", f_equal},
{"EVAL", f_eval},
{"FIX", f_fix},
{"IF", f_if},
{"INDEX", f_index},
{"LOWER", f_lower},
{"NTH", f_nth},
{"OR", f_or},
{"STRCMP", f_strcmp},
{"STRFILL", f_strfill},
{"STRLEN", f_strlen},
{"STRSTR", f_strstr},
{"SUBSTR", f_substr},
{"UPPER", f_upper},
{"XOR", f_xor},
{(char *)"+", f_plus},
{(char *)"-", f_minus},
{(char *)"*", f_times},
{(char *)"/", f_divide},
{(char *)"=", f_numeq},
{(char *)"<", f_numlt},
{(char *)">", f_numgt},
{(char *)"!=", f_numne},
{(char *)"<=", f_numle},
{(char *)">=", f_numge},
{(char *)"AND", f_and},
{(char *)"EQ", f_equal},
{(char *)"EVAL", f_eval},
{(char *)"FIX", f_fix},
{(char *)"IF", f_if},
{(char *)"INDEX", f_index},
{(char *)"LOWER", f_lower},
{(char *)"NTH", f_nth},
{(char *)"OR", f_or},
{(char *)"STRCMP", f_strcmp},
{(char *)"STRFILL", f_strfill},
{(char *)"STRLEN", f_strlen},
{(char *)"STRSTR", f_strstr},
{(char *)"SUBSTR", f_substr},
{(char *)"UPPER", f_upper},
{(char *)"XOR", f_xor},
#ifdef UNIXTENSIONS
{"EDTIME", f_edtime},
{"GETENV", f_getenv},
{"TIME", f_time},
{(char *)"EDTIME", f_edtime},
{(char *)"GETENV", f_getenv},
{(char *)"TIME", f_time},
#endif /* UNIXTENSIONS */
#ifdef VARIABLES
{"CLEAR", f_clear},
{"GETVAR", f_getvar},
{"SETVAR", f_setvar},
{(char *)"CLEAR", f_clear},
{(char *)"GETVAR", f_getvar},
{(char *)"SETVAR", f_setvar},
#endif /* VARIABLES */
};
@ -1595,7 +1595,7 @@ static int macrovalue(int nargs, char *args, char *output)
int i;
for (i = 0; i < MAXARGS; i++) {
argv[i] = "";
argv[i] = (char *)"";
}
for (i = 0; i < nargs; i++) {
argv[i] = args;
@ -1664,18 +1664,18 @@ static int macroeval(char **in, char **out)
char *ip = *in, *op = *out;
char margs[MAXSTR], mvalue[MAXSTR];
char *ma = margs;
int stat, nargs;
int mstat, nargs;
nargs = stat = macromode(&ip, &ma);
nargs = mstat = macromode(&ip, &ma);
if (stat > 0) {
if (mstat > 0) {
#ifdef ECHOMAC
*op++ = ' ';
*op++ = '<';
V sprintf(op, "(%d)", stat);
V sprintf(op, "(%d)", mstat);
op += strlen(op);
ma = margs;
while (stat-- > 0) {
while (mstat-- > 0) {
int l = strlen(ma);
V strcpy(op, ma);
@ -1689,25 +1689,25 @@ static int macroeval(char **in, char **out)
/* Evaluate the macro. */
stat = macrovalue(nargs, margs, mvalue);
mstat = macrovalue(nargs, margs, mvalue);
V strcpy(op, mvalue);
op += strlen(mvalue);
#ifdef ECHOMAC
if (stat == FALSE || stat == DIAGNOSTIC) {
if (mstat == FALSE || mstat == DIAGNOSTIC) {
V strcpy(op, "*ERR*");
op += 5;
}
*op++ = ' ';
#endif
} else {
stat = FALSE;
mstat = FALSE;
}
*op++ = EOS;
*out = op;
*in = ip;
return stat;
return mstat;
}
/* DIESEL -- Evaluate a string IN and return the value in OUT.
@ -1715,19 +1715,19 @@ static int macroeval(char **in, char **out)
error was detected, returns the column at which the
error was found. */
int diesel(const char *in, char *out)
int diesel(char *in, char *out)
{
int stat;
int dstat;
char *inp = in, *outp = out;
while (TRUE) {
stat = copymode(&inp, &outp);
if (stat == 1) {
dstat = copymode(&inp, &outp);
if (dstat == 1) {
char margs[MAXSTR];
char *ma = margs;
stat = macroeval(&inp, &ma);
if (stat > 0) {
dstat = macroeval(&inp, &ma);
if (dstat > 0) {
/* If we're about to overflow the output string, bail
out of the evaluation and append the overflow
@ -1749,7 +1749,7 @@ int diesel(const char *in, char *out)
/* Error detected in macro evaluation which placed a
diagnostic string in the output. */
if (stat == DIAGNOSTIC) {
if (dstat == DIAGNOSTIC) {
return inp - in;
}
} else {
@ -1758,147 +1758,9 @@ int diesel(const char *in, char *out)
}
}
return stat;
return dstat;
}
void MacroVars( const char *codes, const char *fmt, ...)
{
char *tmp1, *tmp2;
va_list ap;
int j;
int dieselrc;
char *vs;
int vd;
char vc;
double vf;
tmp1=calloc(256,sizeof(char));
tmp2=calloc(256,sizeof(char));
va_start(ap,fmt);
for ( j=0; (codes[j] != '\0') && (fmt[j] != '\0') ; j++ ){
tmp1[0]='\0';
switch(fmt[j]) {
case 's': /* string */
vs = va_arg(ap, char *);
sprintf(tmp1,"@(setvar,%c,%s)",codes[j],vs);
break;
case 'd': /* int */
vd = va_arg(ap, int);
sprintf(tmp1,"@(setvar,%c,%d)",codes[j],vd);
break;
case 'c': /* char */
vc = va_arg(ap, char);
sprintf(tmp1,"@(setvar,%c,%c)",codes[j],vc);
break;
case 'f': /* char */
vf = va_arg(ap, double);
sprintf(tmp1,"@(setvar,%c,%f)",codes[j],vf);
break;
}
dieselrc=diesel(tmp1,tmp2);
}
va_end(ap);
free(tmp1);
free(tmp2);
}
void MacroClear(void)
{
int dieselrc;
char tmp1[]="@(CLEAR)",*tmp2;
tmp2=calloc(10,sizeof(char));
dieselrc=diesel(tmp1,tmp2);
free(tmp2);
}
char *ParseMacro( const char *line, int *dieselrc)
{
static char res[256];
char *tmp1,*tmp2,*tmp3;
char *i;
int j;
int l;
char code;
res[0]='\0';
*dieselrc=0;
if ( *line == '#' )
return res;
tmp1 = calloc(256,sizeof(char));
tmp2 = calloc(256,sizeof(char));
tmp3 = calloc(256,sizeof(char));
tmp1[0]='\0';
for ( i=line ; i[0] != '\0'; i++){
if ( (i[0] == '@') && isalpha(i[1]) ){
l=2;
i++;
if (i[0] != '@') {
if ((code = i[0]) != '\0' )
i++;
while (( i[0] == '_') || ( i[0] == '>') || ( i[0] == '<') ){
l++;
i++;
}
i--;
sprintf(tmp2,"@(GETVAR,%c)",code);
if (!diesel(tmp2,tmp3)==0){
sprintf(tmp3,"%c%c",'@',code);
}
if (l>2){
if ( *i != '>')
l=-l;
sprintf(&tmp1[strlen(tmp1)],"%*.*s",l,l, tmp3);
}else{
sprintf(&tmp1[strlen(tmp1)],"%s",tmp3);
}
}else{
tmp1[(j=strlen(tmp1))]='@';
tmp1[j+1]='\0';
}
}else{
tmp1[(j=strlen(tmp1))]=i[0];
tmp1[j+1]='\0';
}
}
i = tmp1;
sprintf(tmp2,"%s",tmp1);
if ((tmp1[0]=='@') && (tmp1[1]=='{')){
i++;
i++;
for (j=2; ((tmp1[j]!='}') && (tmp1[j]!='\0'));j++){
i++;
}
if ( (tmp1[j]=='}') ){
i++;
res[0]='\0';
if (j>2)
sprintf(res,"%.*s",j-2,&tmp1[2]);
if ((diesel(res,tmp3)!=0) || (atoi(tmp3)==0))
sprintf(tmp2,"@!%s",i);
else
sprintf(tmp2,"%s",i);
}
}
*dieselrc=diesel(tmp2, res);
free(tmp1);
free(tmp2);
free(tmp3);
while (isspace(res[strlen(res) - 1])) {
res[strlen(res) - 1] = EOS;
}
sprintf(&res[strlen(res)],"\r\n");
if ((res[0] == '@') && (res[1] =='!' ))
res[0]='\0';
return res;
}
#ifdef TESTPROG

View File

@ -39,15 +39,15 @@ int tracing = TRUE; /* Trace macro evalution */
#define FUZZEQ(a, b) ((((a) < (b)) ? ((b) - (a)) : ((a) - (b))) < 1E-10)
int diesel(const char *, char *);
char *ParseMacro( const char *, int * );
void MacroVars( const char *, const char *, ... );
void MacroClear(void);
int diesel(char *, char *);
/*
* MBSE BBS specific functions
*/
char *ParseMacro( const char *, int * );
void MacroVars( const char *, const char *, ... );
void MacroClear(void);
FILE *OpenMacro(const char *, int);
#endif

View File

@ -36,6 +36,155 @@
#include "diesel.h"
void MacroVars( const char *codes, const char *fmt, ...)
{
char *tmp1, *tmp2;
va_list ap;
int j;
int dieselrc;
char *vs;
int vd;
char vc;
double vf;
tmp1=calloc(256,sizeof(char));
tmp2=calloc(256,sizeof(char));
va_start(ap,fmt);
for ( j=0; (codes[j] != '\0') && (fmt[j] != '\0') ; j++ ){
tmp1[0]='\0';
switch(fmt[j]) {
case 's': /* string */
vs = va_arg(ap, char *);
sprintf(tmp1,"@(setvar,%c,\"%s\")",codes[j],vs);
break;
case 'd': /* int */
vd = va_arg(ap, int);
sprintf(tmp1,"@(setvar,%c,%d)",codes[j],vd);
break;
case 'c': /* char */
vc = va_arg(ap, char);
sprintf(tmp1,"@(setvar,%c,%c)",codes[j],vc);
break;
case 'f': /* char */
vf = va_arg(ap, double);
sprintf(tmp1,"@(setvar,%c,%f)",codes[j],vf);
break;
}
dieselrc=diesel(tmp1,tmp2);
if (dieselrc) {
Syslog('!', "MacroVars error %d argument %d", dieselrc, j);
}
}
va_end(ap);
free(tmp1);
free(tmp2);
}
void MacroClear(void)
{
int dieselrc;
char tmp1[] = "@(CLEAR)", *tmp2;
tmp2 = calloc(10,sizeof(char));
dieselrc = diesel(tmp1, tmp2);
if (dieselrc)
Syslog('!', "MacroClear error %d", dieselrc);
free(tmp2);
}
char *ParseMacro( const char *line, int *dieselrc)
{
static char res[256];
char *tmp1, *tmp2, *tmp3, *i;
int j, l;
char code;
res[0]='\0';
*dieselrc=0;
if ( *line == '#' )
return res;
tmp1 = calloc(256,sizeof(char));
tmp2 = calloc(256,sizeof(char));
tmp3 = calloc(256,sizeof(char));
tmp1[0]='\0';
for ( i=line ; i[0] != '\0'; i++){
if ( (i[0] == '@') && isalpha(i[1]) ){
l=2;
i++;
if (i[0] != '@') {
if ((code = i[0]) != '\0' )
i++;
while (( i[0] == '_') || ( i[0] == '>') || ( i[0] == '<') ){
l++;
i++;
}
i--;
sprintf(tmp2,"@(GETVAR,%c)",code);
if (!diesel(tmp2,tmp3)==0){
sprintf(tmp3,"%c%c",'@',code);
}
if (l>2){
if ( *i != '>')
l=-l;
sprintf(&tmp1[strlen(tmp1)],"%*.*s",l,l, tmp3);
}else{
sprintf(&tmp1[strlen(tmp1)],"%s",tmp3);
}
}else{
tmp1[(j=strlen(tmp1))]='@';
tmp1[j+1]='\0';
}
}else{
tmp1[(j=strlen(tmp1))]=i[0];
tmp1[j+1]='\0';
}
}
i = tmp1;
sprintf(tmp2,"%s",tmp1);
if ((tmp1[0]=='@') && (tmp1[1]=='{')){
i++;
i++;
for (j=2; ((tmp1[j]!='}') && (tmp1[j]!='\0'));j++){
i++;
}
if ( (tmp1[j]=='}') ){
i++;
res[0]='\0';
if (j>2)
sprintf(res,"%.*s",j-2,&tmp1[2]);
if ((diesel(res,tmp3)!=0) || (atoi(tmp3)==0))
sprintf(tmp2,"@!%s",i);
else
sprintf(tmp2,"%s",i);
}
}
*dieselrc=diesel(tmp2, res);
free(tmp1);
free(tmp2);
free(tmp3);
while (isspace(res[strlen(res) - 1])) {
res[strlen(res) - 1] = EOS;
}
// sprintf(&res[strlen(res)],"\r\n");
if ((res[0] == '@') && (res[1] =='!' ))
res[0]='\0';
return res;
}
FILE *OpenMacro(const char *filename, int Language)
{

View File

@ -43,7 +43,8 @@ MBMSG_OBJS = post.o mbmsg.o
MBFIDO_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
../lib/libdbase.a ../lib/libdiesel.a ../lib/libmbinet.a
MBSEQ_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBAFF_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a ../lib/libdbase.a
MBAFF_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
../lib/libdbase.a ../lib/libdiesel.a
MBINDEX_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBDIFF_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
MBFILE_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
@ -163,12 +164,12 @@ post.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/co
rnews.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/dbdupe.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/msg.h ../lib/msgtext.h pack.h rfc2ftn.h mbfido.h paths.h rnews.h
storenet.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbmsgs.h ../lib/dbuser.h rollover.h storenet.h
utic.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h tic.h mover.h tic.h utic.h
announce.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h grlist.h msgutil.h announce.h
announce.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h grlist.h msgutil.h announce.h
fflist.o: ../lib/libs.h ../lib/clcomm.h ../lib/msg.h fflist.h
ftn2rfc.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/dbftn.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/common.h ../lib/clcomm.h rollover.h aliasdb.h postemail.h backalias.h ftn2rfc.h
makestat.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h makestat.h
mbindex.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbftn.h mbindex.h
msgutil.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h msgutil.h
msgutil.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/msg.h ../lib/msgtext.h ../lib/diesel.h msgutil.h
postecho.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h ../lib/msgtext.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbmsgs.h ../lib/dbdupe.h ../lib/dbuser.h ../lib/dbftn.h ftn2rfc.h postecho.h storeecho.h addpkt.h rollover.h
rollover.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h rollover.h
tic.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbftn.h ../lib/clcomm.h ulock.h ptic.h fsort.h pack.h tic.h

View File

@ -38,6 +38,7 @@
#include "../lib/dbcfg.h"
#include "../lib/msg.h"
#include "../lib/msgtext.h"
#include "../lib/diesel.h"
#include "grlist.h"
#include "msgutil.h"
#include "announce.h"
@ -57,36 +58,35 @@ int MsgCount; /* Message counter */
int Add_ToBeRep(void);
int Add_ToBeRep()
{
char *fname;
struct _filerecord Temp;
FILE *tbr;
int Found = FALSE;
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);
free(fname);
return 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);
free(fname);
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;
}
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);
fclose(tbr);
return FALSE;
}
fwrite(&T_File, sizeof(T_File), 1, tbr);
if (Found) {
Syslog('!', "File %s already in toberep.data", T_File.Name);
fclose(tbr);
return TRUE;
return FALSE;
}
fwrite(&T_File, sizeof(T_File), 1, tbr);
fclose(tbr);
return TRUE;
}
@ -98,377 +98,429 @@ int Add_ToBeRep()
void Uploads(void);
void Uploads()
{
FILE *pAreas, *pFile;
char *sAreas, *fAreas;
int Count = 0, i = 0, j, k;
FILE *pAreas, *pFile;
char *sAreas, *fAreas;
int Count = 0, i = 0, j, k;
sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = calloc(PATH_MAX, sizeof(char));
Syslog('+', "Checking for uploads");
IsDoing("Check uploads");
Syslog('+', "Checking for uploads");
IsDoing("Check uploads");
if (!do_quiet) {
colour(3, 0);
printf(" Checking uploads...\n");
}
if (!do_quiet) {
colour(3, 0);
printf(" Checking uploads...\n");
}
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);
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
i++;
if (CFG.slow_util && do_quiet)
usleep(1);
if ((area.Available) && strlen(area.NewGroup)) {
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);
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++;
}
}
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);
}
}
fclose(pFile);
}
}
}
if (!do_quiet) {
printf("\r \r");
if (Count)
printf(" %d new uploads\n", Count);
fflush(stdout);
}
if (Count)
Syslog('+', "%d new uploads", Count);
fclose(pAreas);
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);
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
i++;
int StartMsg(void);
int StartMsg(void)
{
if (!Msg_Open(newfiles.Area))
return FALSE;
if (CFG.slow_util && do_quiet)
usleep(1);
if (!Msg_Lock(30L)) {
Msg_Close();
return FALSE;
if ((area.Available) && strlen(area.NewGroup)) {
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);
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++;
}
}
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);
}
}
fclose(pFile);
}
}
Msg_New();
}
CountPosted(newfiles.Area);
if (!do_quiet) {
printf("\r \r");
if (Count)
printf(" %d new uploads\n", Count);
fflush(stdout);
}
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();
Msg_Top();
return TRUE;
if (Count)
Syslog('+', "%d new uploads", Count);
fclose(pAreas);
free(sAreas);
free(fAreas);
}
void FinishMsg(int);
void FinishMsg(int Final)
long StartMsg(void);
long StartMsg(void)
{
char *temp;
FILE *fp;
if (!Msg_Open(newfiles.Area))
return -1;
temp = calloc(PATH_MAX, sizeof(char));
if (!Msg_Lock(30L)) {
Msg_Close();
return -1;
}
Msg_New();
if (Final) {
MsgText_Add2((char *)"");
sprintf(temp, "This is a total of %d files, %lu Kbytes", TotalFiles, TotalSize);
MsgText_Add2(temp);
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);
}
void FinishMsg(int, long);
void FinishMsg(int Final, long filepos)
{
char *temp;
FILE *fp, *fi;
temp = calloc(PATH_MAX, sizeof(char));
if (Final) {
if ((fi = OpenMacro(newfiles.Template, newfiles.Language)) != NULL) {
MacroVars("CD", "dd", TotalFiles, TotalSize);
fseek(fi, filepos, SEEK_SET);
Msg_Macro(fi);
fclose(fi);
MacroClear();
} else {
MsgText_Add2((char *)"");
sprintf(temp, "This is a total of %d files, %lu Kbytes", TotalFiles, TotalSize);
MsgText_Add2(temp);
MsgText_Add2((char *)"");
sprintf(temp, "With regards, %s", CFG.sysop_name);
MsgText_Add2(temp);
}
}
if (strlen(newfiles.Origin))
Msg_Bot(newfiles.UseAka, newfiles.Origin, newfiles.Template);
else
Msg_Bot(newfiles.UseAka, CFG.origin, newfiles.Template);
Msg_AddMsg();
Msg_UnLock();
Syslog('+', "Posted message %ld, %d bytes", Msg.Id, Msg.Size);
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();
free(temp);
}
long Report(gr_list *, long);
long Report(gr_list *ta, long filepos)
{
FILE *fp, *fi;
char *temp, *line;
int i, Total = 0;
unsigned long Size = 0;
long filepos1 = 0, filepos2, filepos3 = 0, finalpos = 0;
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;
}
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
if ((!strcmp(T_File.Echo, ta->echo)) && (!strcmp(T_File.Group, ta->group)))
break;
}
if ((fi = OpenMacro(newfiles.Template, newfiles.Language)) != NULL) {
MacroVars("GHZ", "ssd", T_File.Echo, T_File.Comment, 0);
fseek(fi, filepos, SEEK_SET);
Msg_Macro(fi);
filepos1 = ftell(fi);
} else {
sprintf(temp, "Area %s - %s", T_File.Echo, T_File.Comment);
MsgText_Add2(temp);
MsgText_Add2((char *)"------------------------------------------------------------------------");
}
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)
usleep(1);
if (fi != NULL) {
fseek(fi, filepos1, SEEK_SET);
MacroVars("slbkdt", "ssddss", T_File.Name, T_File.LName, T_File.Size, T_File.SizeKb, " ",
To_Low(T_File.LDesc[0],newfiles.HiAscii));
Msg_Macro(fi);
filepos2 = ftell(fi);
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 {
line = calloc(255, sizeof(char));
while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {}
free(line);
}
filepos3 = ftell(fi);
}
} else {
sprintf(temp, "%-12s %5lu Kb. %s", T_File.Name, T_File.SizeKb, To_Low(T_File.LDesc[0],newfiles.HiAscii));
MsgText_Add2(temp);
if (T_File.TotLdesc > 0)
for (i = 1; i < T_File.TotLdesc; i++) {
sprintf(temp, " %s", To_Low(T_File.LDesc[i],newfiles.HiAscii));
MsgText_Add2(temp);
}
}
Total++;
Size += T_File.SizeKb;
/*
* Split message the hard way.
*/
if (Msg.Size > (CFG.new_force * 1024)) {
MacroVars("Z", "d", 1);
MsgText_Add2((char *)"");
MsgText_Add2((char *)"to be continued...");
MsgCount++;
FinishMsg(FALSE, finalpos);
StartMsg();
}
if ((Msg.Size > (CFG.new_split * 1024)) && (fi != NULL)) {
MacroVars("Z", "d", 1);
}
}
if (strlen(newfiles.Origin))
Msg_Bot(newfiles.UseAka, newfiles.Origin);
else
Msg_Bot(newfiles.UseAka, CFG.origin);
Msg_AddMsg();
Msg_UnLock();
Syslog('+', "Posted message %ld, %d bytes", Msg.Id, Msg.Size);
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();
free(temp);
}
void Report(gr_list *);
void Report(gr_list *ta)
{
FILE *fp;
char *temp;
int i, Total = 0;
unsigned long Size = 0;
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;
}
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
if ((!strcmp(T_File.Echo, ta->echo)) &&
(!strcmp(T_File.Group, ta->group)))
break;
}
sprintf(temp, "Area %s - %s", T_File.Echo, T_File.Comment);
MsgText_Add2(temp);
fseek(fp, 0, SEEK_SET);
}
if (fi != NULL) {
MacroVars("AB", "dd", Total, Size);
fseek(fi, filepos3, SEEK_SET);
Msg_Macro(fi);
finalpos = ftell(fi);
} else {
MsgText_Add2((char *)"------------------------------------------------------------------------");
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)
usleep(1);
sprintf(temp, "%-12s %5lu Kb. %s", tu(T_File.Name), T_File.SizeKb, To_Low(T_File.LDesc[0],newfiles.HiAscii));
MsgText_Add2(temp);
if (T_File.TotLdesc > 0)
for (i = 1; i < T_File.TotLdesc; i++) {
sprintf(temp, " %s", To_Low(T_File.LDesc[i],newfiles.HiAscii));
MsgText_Add2(temp);
}
Total++;
Size += T_File.SizeKb;
/*
* Split message the hard way.
*/
if (Msg.Size > (CFG.new_force * 1024)) {
FinishMsg(FALSE);
StartMsg();
}
}
}
MsgText_Add2((char *)"------------------------------------------------------------------------");
sprintf(temp, "%d files, %lu Kb", Total, Size);
MsgText_Add2(temp);
MsgText_Add2((char *)"");
MsgText_Add2((char *)"");
fclose(fp);
free(temp);
}
/*
* Split messages the gently way.
*/
if (Msg.Size > (CFG.new_split * 1024)) {
FinishMsg(FALSE);
StartMsg();
}
fclose(fp);
free(temp);
TotalFiles += Total;
TotalSize += Size;
/*
* Split messages the gently way.
*/
if (Msg.Size > (CFG.new_split * 1024)) {
MsgText_Add2((char *)"");
MsgText_Add2((char *)"to be continued...");
MsgCount++;
FinishMsg(FALSE, finalpos);
StartMsg();
}
TotalFiles += Total;
TotalSize += Size;
if (fi != NULL) {
fclose(fi);
}
return finalpos;
}
int Announce()
{
gr_list *fgr = NULL, *tmp;
char *temp;
FILE *fp;
int Count = 0, rc = FALSE;
long filepos;
char group[13];
int i, groups, any;
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");
}
if (!do_quiet) {
colour(3, 0);
printf("Announce new files\n");
}
Uploads();
IsDoing("Announce files");
temp = calloc(128, sizeof(char));
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) {
Syslog('+', "No new files to announce");
free(temp);
if (!do_quiet) {
printf(" No new files.\n");
}
return FALSE;
}
if (!do_quiet)
printf(" Preparing reports...\n");
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
if (T_File.Announce) {
fill_grlist(&fgr, T_File.Group, T_File.Echo);
Count++;
}
}
fclose(fp);
if (Count == 0) {
unlink(temp);
if (!do_quiet)
printf(" No new files.\n");
Syslog('+', "No new files to announce");
free(temp);
return FALSE;
}
if (!do_quiet)
printf(" %d new files found\n", Count);
sort_grlist(&fgr);
/*
* 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 (StartMsg()) {
while (fread(&group, 13, 1, fp) == 1) {
for (tmp = fgr; tmp; tmp = tmp->next)
if (!strcmp(tmp->group, group)) {
Report(tmp);
}
}
}
FinishMsg(TRUE);
} else {
if (!do_quiet)
printf(" No matching groups\n");
}
fseek(fp, filepos, SEEK_SET);
}
fseek(fp, newfileshdr.grpsize, SEEK_CUR);
}
fclose(fp);
tidy_grlist(&fgr);
if (rc) {
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
unlink(temp);
}
Uploads();
IsDoing("Announce files");
temp = calloc(128, sizeof(char));
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) == NULL) {
Syslog('+', "No new files to announce");
free(temp);
return rc;
if (!do_quiet) {
printf(" No new files.\n");
}
return FALSE;
}
if (!do_quiet)
printf(" Preparing reports...\n");
while (fread(&T_File, sizeof(T_File), 1, fp) == 1) {
if (T_File.Announce) {
fill_grlist(&fgr, T_File.Group, T_File.Echo);
Count++;
}
}
fclose(fp);
if (Count == 0) {
unlink(temp);
if (!do_quiet)
printf(" No new files.\n");
Syslog('+', "No new files to announce");
free(temp);
return FALSE;
}
if (!do_quiet)
printf(" %d new files found\n", Count);
sort_grlist(&fgr);
/*
* 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) {
for (tmp = fgr; tmp; tmp = tmp->next)
if (!strcmp(tmp->group, group)) {
filepos2 = Report(tmp, filepos1);
}
}
FinishMsg(TRUE, filepos2);
}
} else {
if (!do_quiet)
printf(" No matching groups\n");
}
fseek(fp, filepos, SEEK_SET);
}
fseek(fp, newfileshdr.grpsize, SEEK_CUR);
}
fclose(fp);
tidy_grlist(&fgr);
if (rc) {
sprintf(temp, "%s/etc/toberep.data", getenv("MBSE_ROOT"));
unlink(temp);
}
free(temp);
return rc;
}

View File

@ -83,8 +83,7 @@ void A_Help(faddr *, char *);
void A_Help(faddr *t, char *replyid)
{
FILE *fp, *fi;
char *line,*subject;
int res;
char *subject;
Syslog('+', "AreaMgr: Help");
@ -95,12 +94,8 @@ void A_Help(faddr *t, char *replyid)
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject , replyid)) != NULL) {
if ((fi = OpenMacro("areamgr.help", nodes.Language)) != NULL ){
line = calloc(255, sizeof(char));
while ( fgets(line, 254, fi) != NULL ){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, fp);
MacroClear();
free(line);
fclose(fi);
}else{
fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Areamgr");
@ -160,8 +155,8 @@ void A_Query(faddr *t, char *replyid)
void A_List(faddr *t, char *replyid, int Notify)
{
FILE *qp, *gp, *mp, *fi;
char *temp, *Group, *line, *subject;
int i, First = TRUE, SubTot, Total = 0, Cons, res;
char *temp, *Group, *subject;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[5];
faddr *f, *g;
sysconnect System;
@ -221,11 +216,8 @@ void A_List(faddr *t, char *replyid, int Notify)
fi=OpenMacro("areamgr.query", nodes.Language);
if (Notify>=LIST_UNLINK)
fi=OpenMacro("areamgr.unlink", nodes.Language);
line=calloc(256,sizeof(char));
if (fi != NULL){
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr);
}else{
fprintf(qp, "The following is a list of message areas\r\r");
@ -235,7 +227,6 @@ void A_List(faddr *t, char *replyid, int Notify)
if ((mp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
free(subject);
MacroClear();
return;
@ -247,7 +238,6 @@ void A_List(faddr *t, char *replyid, int Notify)
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
free(subject);
MacroClear();
fclose(mp);
@ -272,9 +262,7 @@ void A_List(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("GHI", "sss",mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka) );
fsetpos(fi,&fileptr);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr1);
}else{
fprintf(qp, "Group %s - %s (%s)\r\r", mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka));
@ -318,9 +306,7 @@ void A_List(faddr *t, char *replyid, int Notify)
(Stat[3] == 'C')
);
fsetpos(fi,&fileptr1);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr2);
}else{
fprintf(qp, "%s %-25s %s\r", Stat, msgs.Tag, msgs.Name);
@ -334,16 +320,14 @@ void A_List(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("ZA", "dd", (int) 0 , SubTot );
fsetpos(fi,&fileptr2);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
MacroVars("Z","d",1);
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
CloseMail(qp, t);
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid);
msgptr = ftell(qp);
}
fprintf( qp, "%s", ParseMacro(line,&res));
}
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
MacroVars("Z","d",1);
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
CloseMail(qp, t);
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid);
msgptr = ftell(qp);
}
MacroRead(fi, qp);
}else{
fprintf(qp, "----------------------------------------------------------------------------\r");
fprintf(qp, "%d area(s)\r\r\r", SubTot);
@ -361,9 +345,7 @@ void A_List(faddr *t, char *replyid, int Notify)
}
if (fi != NULL){
MacroVars("B", "d", Total );
while ( fgets(line, 254, fi) != NULL ){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
MacroClear();
fclose(fi);
}else{
@ -378,7 +360,6 @@ void A_List(faddr *t, char *replyid, int Notify)
}
fclose(mp);
fclose(gp);
free(line);
fprintf(qp, "%s\r", TearLine());
CloseMail(qp, t);
} else
@ -392,8 +373,8 @@ void A_List(faddr *t, char *replyid, int Notify)
void A_Flow(faddr *t, char *replyid, int Notify)
{
FILE *qp, *gp, *mp, *fi;
char *temp, *Group, *line, *subject;
int i, First = TRUE, Cons, res;
char *temp, *Group, *subject;
int i, First = TRUE, Cons;
char Stat[2];
faddr *f, *g;
sysconnect System;
@ -446,12 +427,10 @@ void A_Flow(faddr *t, char *replyid, int Notify)
msgptr = ftell(qp);
temp = calloc(PATH_MAX, sizeof(char));
line = calloc(256, sizeof(char));
sprintf(temp, "%s/etc/mareas.data", getenv("MBSE_ROOT"));
if ((mp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
free(subject);
return;
}
@ -462,7 +441,6 @@ void A_Flow(faddr *t, char *replyid, int Notify)
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
free(subject);
fclose(mp);
return;
@ -470,9 +448,7 @@ void A_Flow(faddr *t, char *replyid, int Notify)
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
free(temp);
if (fi != NULL){
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr);
}else{
fprintf(qp, "The following is a flow report of all message areas\r\r");
@ -494,9 +470,7 @@ void A_Flow(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("GHI", "sss",mgroup.Name, mgroup.Comment, aka2str(mgroup.UseAka) );
fsetpos(fi,&fileptr);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr1);
}else{
fprintf(qp, "Group %s - %s\r\r", mgroup.Name, mgroup.Comment);
@ -534,9 +508,7 @@ void A_Flow(faddr *t, char *replyid, int Notify)
(Stat[0] == 'C')
);
fsetpos(fi,&fileptr1);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr2);
}else{
fprintf(qp, "%s %s %9lu %10lu\r", Stat, padleft(msgs.Tag, 50, ' '),
@ -554,16 +526,14 @@ void A_Flow(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("ZBCDbcd", "ddddddd", (int) 0 , rlw, rlm, rlt, plw, plm, plt);
fsetpos(fi,&fileptr2);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
MacroVars("Z","d",1);
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
CloseMail(qp, t);
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid);
msgptr = ftell(qp);
}
fprintf( qp, "%s", ParseMacro(line,&res));
}
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
MacroVars("Z","d",1);
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
CloseMail(qp, t);
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid);
msgptr = ftell(qp);
}
MacroRead(fi, qp);
}else{
fprintf(qp, "---------------------------------------------------------------------------\r");
fprintf(qp, "Total %58lu %10lu\r\r\r", rlw, rlm);
@ -579,10 +549,8 @@ void A_Flow(faddr *t, char *replyid, int Notify)
}
}
}
if (fi != NULL){
while ( fgets(line, 254, fi) != NULL ){
fprintf( qp, "%s", ParseMacro(line,&res));
}
if (fi != NULL){
MacroRead(fi, qp);
MacroClear();
fclose(fi);
}else{
@ -595,7 +563,6 @@ void A_Flow(faddr *t, char *replyid, int Notify)
fclose(mp);
fclose(gp);
free(line);
} else
WriteError("Can't create netmail");
free(subject);
@ -607,8 +574,8 @@ void A_Status(faddr *, char *);
void A_Status(faddr *t, char *replyid)
{
FILE *fp, *fi;
int i,res;
char *line, *subject;
int i;
char *subject;
subject = calloc(255, sizeof(char));
sprintf(subject,"AreaMgr Status");
@ -641,11 +608,7 @@ void A_Status(faddr *t, char *replyid)
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Areamgr", subject, replyid)) != NULL) {
if ( (fi=OpenMacro("areamgr.status", nodes.Language)) != NULL ){
line = calloc(255, sizeof(char));
while ( fgets(line, 254, fi) != NULL ){
fprintf( fp, "%s", ParseMacro(line,&res));
}
free(line);
MacroRead(fi, fp);
fclose(fi);
}else{
fprintf(fp, "Here is your (echo)mail status:\r\r");

View File

@ -198,7 +198,7 @@ int StartReply(ff_list *ffl)
MsgText_Add2(temp);
Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp));
Msg_Pid();
Msg_Top();
Msg_Top(scanmgr.template, scanmgr.Language, scanmgr.Aka);
return TRUE;
}
@ -224,9 +224,9 @@ void FinishReply(int Reported, int Total)
}
if (strlen(scanmgr.Origin))
Msg_Bot(scanmgr.Aka, scanmgr.Origin);
Msg_Bot(scanmgr.Aka, scanmgr.Origin, scanmgr.template);
else
Msg_Bot(scanmgr.Aka, CFG.origin);
Msg_Bot(scanmgr.Aka, CFG.origin, scanmgr.template);
Msg_AddMsg();
Msg_UnLock();
Syslog('+', "Posted message %ld", Msg.Id);

View File

@ -78,8 +78,7 @@ void F_Help(faddr *, char *);
void F_Help(faddr *t, char *replyid)
{
FILE *fp, *fi;
char *line,*subject;
int res;
char *subject;
Syslog('+', "FileMgr: Help");
subject=calloc(255,sizeof(char));
@ -89,13 +88,9 @@ void F_Help(faddr *t, char *replyid)
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
if ( (fi=OpenMacro("filemgr.help", nodes.Language)) != NULL ){
line = calloc(255, sizeof(char));
MacroVars("SNAP", "ssss", nodes.Sysop, (char *)"Filemgr", ascfnode(bestaka_s(t), 0xf), nodes.Fpasswd );
while ( fgets(line, 254, fi) != NULL ){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, fp);
MacroClear();
free(line);
fclose(fi);
}else{
fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Filemgr");
@ -155,8 +150,8 @@ void F_Query(faddr *t, char *replyid)
void F_List(faddr *t, char *replyid, int Notify)
{
FILE *qp, *gp, *fp, *fi;
char *temp, *Group, *line, *subject;
int i, First = TRUE, SubTot, Total = 0, Cons, res;
char *temp, *Group, *subject;
int i, First = TRUE, SubTot, Total = 0, Cons;
char Stat[4];
faddr *f, *g;
sysconnect System;
@ -215,11 +210,8 @@ void F_List(faddr *t, char *replyid, int Notify)
fi=OpenMacro("filemgr.query", nodes.Language);
if (Notify>=LIST_UNLINK)
fi=OpenMacro("filemgr.unlink", nodes.Language);
line=calloc(256,sizeof(char));
if (fi != NULL){
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr);
}else{
fprintf(qp, "The following is a list of file areas\r\r");
@ -229,7 +221,6 @@ void F_List(faddr *t, char *replyid, int Notify)
if ((fp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
free(subject);
MacroClear();
return;
@ -241,7 +232,6 @@ void F_List(faddr *t, char *replyid, int Notify)
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
free(subject);
MacroClear();
fclose(fp);
@ -266,9 +256,7 @@ void F_List(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("GHI", "sss",fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka) );
fsetpos(fi,&fileptr);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr1);
}else{
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
@ -309,9 +297,7 @@ void F_List(faddr *t, char *replyid, int Notify)
(Stat[2] == 'P')
);
fsetpos(fi,&fileptr1);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
fgetpos(fi,&fileptr2);
}else{
fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment);
@ -325,16 +311,14 @@ void F_List(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("ZA", "dd", (int) 0 , SubTot );
fsetpos(fi,&fileptr2);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
MacroVars("Z","d",1);
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
CloseMail(qp, t);
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid);
msgptr = ftell(qp);
}
fprintf( qp, "%s", ParseMacro(line,&res));
}
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
MacroVars("Z","d",1);
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
CloseMail(qp, t);
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid);
msgptr = ftell(qp);
}
MacroRead(fi, qp);
}else{
fprintf(qp, "------------------------------------------------------------------------\r");
fprintf(qp, "%d available area(s)\r\r\r", SubTot);
@ -353,9 +337,7 @@ void F_List(faddr *t, char *replyid, int Notify)
if (fi != NULL){
MacroVars("B", "d", Total );
while ( fgets(line, 254, fi) != NULL ){
fprintf( qp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, qp);
MacroClear();
fclose(fi);
}else{
@ -369,7 +351,6 @@ void F_List(faddr *t, char *replyid, int Notify)
}
fclose(fp);
fclose(gp);
free(line);
fprintf(qp, "%s\r", TearLine());
CloseMail(qp, t);
} else
@ -384,8 +365,8 @@ void F_Status(faddr *, char *);
void F_Status(faddr *t, char *replyid)
{
FILE *fp, *fi;
int i,res;
char *line,*subject;
int i;
char *subject;
subject = calloc(255, sizeof(char));
sprintf(subject,"FileMgr Status");
@ -424,12 +405,8 @@ void F_Status(faddr *t, char *replyid)
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
if ( (fi=OpenMacro("filemgr.status", nodes.Language)) != NULL ){
line = calloc(255, sizeof(char));
while ( fgets(line, 254, fi) != NULL ){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, fp);
MacroClear();
free(line);
fclose(fi);
}else{
fprintf(fp, "Here is your fileecho status:\r\r");

View File

@ -45,36 +45,67 @@
extern int net_out;
void MacroRead(FILE *fi, FILE *fp)
{
char *line, *temp;
int res;
line = calloc(256, sizeof(char));
temp = calloc(256, sizeof(char));
while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {
/*
* Skip comment lines
*/
if (line[0] != '#') {
Striplf(line);
if (strlen(line) == 0) {
/*
* Empty lines are just written
*/
fprintf(fp, "\r");
} else {
strncpy(temp, ParseMacro(line,&res), 254);
if (res)
Syslog('!', "Macro error line: \"%s\"", line);
/*
* Only output if something was evaluated
*/
if (strlen(temp))
fprintf(fp, "%s\r", temp);
}
}
}
free(line);
free(temp);
}
/*
* Write Echomail groups list to tempfile
*/
void WriteMailGroups(FILE *fp, faddr *f)
{
int Count = 0, First = TRUE, res;
char *Group, *temp, *line;
int Count = 0, First = TRUE;
char *Group, *temp;
FILE *gp,*fi;
faddr *g;
fpos_t fileptr;
temp = calloc(128, sizeof(char));
line = calloc(256, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
fi=NULL;
fi=OpenMacro("areamgr.group", nodes.Language);
if (fi != NULL){
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( fp, "%s", ParseMacro(line,&res));
}
if ((fi = OpenMacro("areamgr.group", nodes.Language)) != NULL){
MacroRead(fi, fp);
fgetpos(fi,&fileptr);
}else{
} else {
fprintf(fp, "Dear %s\r\r", nodes.Sysop);
fprintf(fp, "The following is a list of mail groups at %s\r\r", ascfnode(f, 0x1f));
}
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
return;
}
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
@ -96,11 +127,9 @@ void WriteMailGroups(FILE *fp, faddr *f)
(g->zone == f->zone) && (g->net == f->net) &&
(g->node == f->node) && (g->point == f->point)) {
if (fi !=NULL){
MacroVars("gh", "ss", mgroup.Name, mgroup.Comment );
fsetpos(fi,&fileptr);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroVars("gh", "ss", mgroup.Name, mgroup.Comment);
fsetpos(fi, &fileptr);
MacroRead(fi, fp);
}else{
fprintf(fp, "%-12s %s\r", mgroup.Name, mgroup.Comment);
}
@ -111,16 +140,13 @@ void WriteMailGroups(FILE *fp, faddr *f)
}
if (fi != NULL){
MacroVars("b", "d", Count );
while ( fgets(line, 254, fi) != NULL ){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, fp);
fclose(fi);
}else{
fprintf(fp, "--------------------------------------------------------------------\r");
fprintf(fp, "%d group(s)\r\r\r", Count);
}
fclose(gp);
free(line);
free(temp);
}
@ -131,21 +157,17 @@ void WriteMailGroups(FILE *fp, faddr *f)
*/
void WriteFileGroups(FILE *fp, faddr *f)
{
int Count = 0, First = TRUE, res;
char *Group, *temp, *line;
int Count = 0, First = TRUE;
char *Group, *temp;
FILE *gp, *fi;
faddr *g;
fpos_t fileptr;
temp = calloc(128, sizeof(char));
line = calloc(256, sizeof(char));
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
fi=NULL;
fi=OpenMacro("filemgr.group", nodes.Language);
if (fi != NULL){
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( fp, "%s", ParseMacro(line,&res));
}
if ((fi = OpenMacro("filemgr.group", nodes.Language)) != NULL){
MacroRead(fi, fp);
fgetpos(fi,&fileptr);
}else{
fprintf(fp, "Dear %s\r\r", nodes.Sysop);
@ -154,7 +176,6 @@ void WriteFileGroups(FILE *fp, faddr *f)
if ((gp = fopen(temp, "r")) == NULL) {
WriteError("$Can't open %s", temp);
free(temp);
free(line);
return;
}
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
@ -178,9 +199,7 @@ void WriteFileGroups(FILE *fp, faddr *f)
if (fi !=NULL){
MacroVars("gh", "ss", fgroup.Name, fgroup.Comment );
fsetpos(fi,&fileptr);
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, fp);
}else{
fprintf(fp, "%-12s %s\r", fgroup.Name, fgroup.Comment);
}
@ -191,16 +210,13 @@ void WriteFileGroups(FILE *fp, faddr *f)
}
if (fi != NULL){
MacroVars("b", "d", Count );
while ( fgets(line, 254, fi) != NULL ){
fprintf( fp, "%s", ParseMacro(line,&res));
}
MacroRead(fi, fp);
fclose(fi);
}else{
fprintf(fp, "--------------------------------------------------------------------\r");
fprintf(fp, "%d group(s)\r\r\r", Count);
}
fclose(gp);
free(line);
free(temp);
}
@ -429,33 +445,41 @@ int UplinkRequest(faddr *t, int FileMgr, char *cmd)
}
void GetRpSubject(const char *report, char* subject)
{
FILE *fi;
char *temp;
int res;
FILE *fi;
char *temp;
int res;
temp = calloc(256,sizeof(char));
if ((fi=OpenMacro(report, nodes.Language))!=NULL){
while ( fgets(temp, 254, fi) != NULL )
if (temp[0] != '#')
ParseMacro(temp,&res);
fclose(fi);
}
res=diesel("@(getvar,subject)",temp);
Syslog('d', "diesel: %d %s", res, temp);
res=diesel((char *)"@(getvar,subject)",temp);
if(res==0)
sprintf(subject,"%s",temp);
free(temp);
}
int MsgResult(const char * report, FILE *fo)
{
FILE *fi;
char *temp;
int res;
FILE *fi;
char *temp;
int res;
temp = calloc(256,sizeof(char));
if ((fi=OpenMacro(report, nodes.Language))!=NULL){
while ( fgets(temp, 254, fi) != NULL ){
fprintf(fo,"%s",ParseMacro(temp,&res));
if (temp[0] != '#')
fprintf(fo,"%s\r",ParseMacro(temp,&res));
}
fclose(fi);
res=1;

View File

@ -4,6 +4,7 @@
#define _MGRUTIL_H
void MacroRead(FILE *, FILE *);
int MsgResult(const char *, FILE * );
void GetRpSubject(const char *, char*);

View File

@ -37,6 +37,7 @@
#include "../lib/dbcfg.h"
#include "../lib/msg.h"
#include "../lib/msgtext.h"
#include "../lib/diesel.h"
#include "msgutil.h"
@ -44,7 +45,8 @@ extern int do_quiet; /* Supress screen output */
/*
* Translation table from Hi-USA-ANSI to Lo-ASCII
* Translation table from Hi-USA-ANSI to Lo-ASCII,
* currently only ANSI graphics are translated.
*/
char lotab[] = {
"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
@ -58,9 +60,9 @@ char lotab[] = {
"\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217"
"\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237"
"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257"
"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277"
"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"
"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"
"\260\261\262\174\053\053\053\053\053\043\174\043\043\053\053\053"
"\053\053\053\053\053\053\053\053\043\043\043\043\043\075\043\053"
"\053\053\053\053\053\053\053\053\053\053\053\333\334\335\336\337"
"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357"
"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"
};
@ -99,12 +101,77 @@ void Msg_Pid(void)
void Msg_Top(void)
void Msg_Macro(FILE *fi)
{
char *temp;
FILE *fp;
char *temp, *line;
int res;
temp = calloc(PATH_MAX, sizeof(char));
temp = calloc(256, sizeof(char));
line = calloc(256, sizeof(char));
while ((fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))) {
/*
* Skip comment lines
*/
if (line[0] != '#') {
Striplf(line);
if (strlen(line) == 0) {
/*
* Empty lines are just written
*/
MsgText_Add2((char *)"");
Syslog('-', " ");
} else {
strncpy(temp, ParseMacro(line,&res), 254);
if (res)
Syslog('!', "Macro error line: \"%s\"", line);
/*
* Only output if something was evaluated
*/
if (strlen(temp)) {
MsgText_Add2(temp);
Syslog('-', "%s", temp);
}
}
}
}
free(line);
free(temp);
}
long Msg_Top(char *template, int language, fidoaddr aka)
{
char *temp;
FILE *fp, *fi;
long fileptr, fileptr1 = 0L;
MacroVars("YSNLTUMH", "ssssssss", aka2str(aka), CFG.sysop_name, CFG.bbs_name, CFG.location,
CFG.comment, CFG.sysop, CFG.sysdomain, CFG.www_url);
temp = calloc(PATH_MAX, sizeof(char));
if ((fi = OpenMacro(template, language))) {
Msg_Macro(fi);
fileptr = ftell(fi);
sprintf(temp, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) != NULL) {
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) {
if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) && ttyinfo.available && strlen(ttyinfo.phone)) {
MacroVars("pqrf", "dsss", ttyinfo.type, ttyinfo.phone, ttyinfo.speed, ttyinfo.flags);
fseek(fi, fileptr, SEEK_SET);
Msg_Macro(fi);
fileptr1 = ftell(fi);
}
}
fclose(fp);
}
fclose(fi);
} else {
sprintf(temp, "System name %s", CFG.bbs_name);
MsgText_Add2(temp);
sprintf(temp, "Sysop %s", CFG.sysop_name);
@ -118,43 +185,42 @@ void Msg_Top(void)
sprintf(temp, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
if ((fp = fopen(temp, "r")) != NULL) {
MsgText_Add2((char *)"Line Phone number Maximum speed Fidonet Flags");
MsgText_Add2((char *)"---- -------------------- -------------------- -------------------------");
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp);
MsgText_Add2((char *)"Line Phone number Maximum speed Fidonet Flags");
MsgText_Add2((char *)"---- -------------------- -------------------- -------------------------");
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp);
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) {
if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) &&
ttyinfo.available && strlen(ttyinfo.phone)) {
switch (ttyinfo.type) {
case POTS: sprintf(temp, "POTS %-20s %-20s %s", ttyinfo.phone, ttyinfo.speed, ttyinfo.flags);
break;
case ISDN: sprintf(temp, "ISDN %-20s %-20s %s", ttyinfo.phone, ttyinfo.speed, ttyinfo.flags);
break;
}
MsgText_Add2(temp);
}
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) {
if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) &&
ttyinfo.available && strlen(ttyinfo.phone)) {
switch (ttyinfo.type) {
case POTS: sprintf(temp, "POTS %-20s %-20s %s", ttyinfo.phone, ttyinfo.speed, ttyinfo.flags);
break;
case ISDN: sprintf(temp, "ISDN %-20s %-20s %s", ttyinfo.phone, ttyinfo.speed, ttyinfo.flags);
break;
}
MsgText_Add2(temp);
}
fclose(fp);
}
fclose(fp);
}
MsgText_Add2((char *)"");
MsgText_Add2((char *)"");
free(temp);
}
free(temp);
return fileptr1;
}
void Msg_Bot(fidoaddr UseAka, char *Org)
void Msg_Bot(fidoaddr UseAka, char *Org, char *template)
{
char *temp, *aka;
temp = calloc(81, sizeof(char));
aka = calloc(40, sizeof(char));
MsgText_Add2((char *)"");
sprintf(temp, "With regards, %s", CFG.sysop_name);
MsgText_Add2(temp);
MsgText_Add2((char *)"");
MsgText_Add2(TearLine());

View File

@ -1,13 +1,16 @@
/* $Id$ */
#ifndef _MSGUTIL_H
#define _MSGUTIL_H
void Msg_Id(fidoaddr);
void Msg_Pid(void);
void Msg_Top(void);
void Msg_Bot(fidoaddr, char *);
void CountPosted(char *);
char *To_Low(char *, int);
void Msg_Id(fidoaddr);
void Msg_Pid(void);
void Msg_Macro(FILE *);
long Msg_Top(char *, int, fidoaddr);
void Msg_Bot(fidoaddr, char *, char *);
void CountPosted(char *);
char *To_Low(char *, int);
#endif