Added DIESEL macro language
This commit is contained in:
parent
cec920a69b
commit
1ccf40e57e
@ -4612,6 +4612,9 @@ v0.33.20 10-Feb-2002
|
|||||||
clcomm.a
|
clcomm.a
|
||||||
Added counter for mailer TCP/IP sessions.
|
Added counter for mailer TCP/IP sessions.
|
||||||
|
|
||||||
|
diesel.a
|
||||||
|
New library for parsing macro templates.
|
||||||
|
|
||||||
mbsetup:
|
mbsetup:
|
||||||
In message groups added default settings for auto area
|
In message groups added default settings for auto area
|
||||||
creation.
|
creation.
|
||||||
|
294
lib/Diesel.doc
Normal file
294
lib/Diesel.doc
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
|
||||||
|
T U R B O D I E S E L
|
||||||
|
Template-based Uncomplicated Report-Building Oriented Dumb
|
||||||
|
Interpretively Evaluated String Expression Language
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
This "Dumb Interpretively Executed String Expression Language" is the
|
||||||
|
kernel of a macro language you can customise by adding C code and
|
||||||
|
embedding it into your program.
|
||||||
|
|
||||||
|
It is short, written in portable C, and is readily integrated into any
|
||||||
|
program. It is useful primarily to programs which need a very rudimentary
|
||||||
|
macro expansion facility without the complexity of a full language such as
|
||||||
|
Lisp or FORTH.
|
||||||
|
|
||||||
|
DIESEL copies its input directly to the output until a macro character,
|
||||||
|
"@" or quoted string is encountered. Quoted strings may be used to
|
||||||
|
suppress evaluation of sequences of characters which would otherwise be
|
||||||
|
interpreted as macros. Quote marks may be included in quoted strings by
|
||||||
|
two adjacent quote marks. For example:
|
||||||
|
|
||||||
|
"@(if,1,True,False)="""@(if,1,True,False)""""
|
||||||
|
|
||||||
|
Status retrieval, computation, and display are performed by DIESEL
|
||||||
|
functions. The available functions are as follows. User-defined
|
||||||
|
functions are not implemented; what you see is all you've got. Naturally,
|
||||||
|
if you embed DIESEL in your application, you'll add functions that provide
|
||||||
|
access to information and actions within your own program. DIESEL's
|
||||||
|
arithmetic functions accept either floating point or integer arguments,
|
||||||
|
and perform all calculations in floating point.
|
||||||
|
|
||||||
|
TURBODIESEL facilities
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
If a line begin with # then will be not evaluated, and any output is done.
|
||||||
|
|
||||||
|
If a line begin with @! any output is done, but evaluation is performed.
|
||||||
|
|
||||||
|
If a line begin with @{<expresion>} produces output only if expression is
|
||||||
|
TRUE (Any non-zero numeric value).
|
||||||
|
|
||||||
|
To easily format output, you can use one-char variable names as follow:
|
||||||
|
|
||||||
|
@A will be replaced by result of evaluate @(GETVAR,A).
|
||||||
|
|
||||||
|
@A_____ will be replaced by result of evaluate @(GETVAR,A) truncated or
|
||||||
|
padded with spaces to complete same lenght of '@A_____' (7 in that case).
|
||||||
|
|
||||||
|
You can use > or < to especify alignement rigth or left:
|
||||||
|
|
||||||
|
@A_____> @A_____<
|
||||||
|
|
||||||
|
|
||||||
|
TURBODIESEL String Functions
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
@(+,<val1>,<val2>,...<valn>)
|
||||||
|
The sum of the numbers <val1>, <val2>, ...<valn> is returned.
|
||||||
|
|
||||||
|
@(-,<val1>,<val2>,...<valn>)
|
||||||
|
The result of subtracting the numbers <val2> through <valn> from
|
||||||
|
<val1> is returned.
|
||||||
|
|
||||||
|
@(*,<val1>,<val2>,...<valn>)
|
||||||
|
The result of multiplying the numbers <val1>,<val2>,...<valn> is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
@(/,<val1>,<val2>,...<valn>)
|
||||||
|
The result of dividing the number <val1> by <val2>,... <valn> is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
@(=,<val1>,<val2>)
|
||||||
|
If the numbers <val1> and <val2> are equal 1 is returned,
|
||||||
|
otherwise 0 is returned.
|
||||||
|
|
||||||
|
@(<,<val1>,<val2>)
|
||||||
|
If the number <val1> is less than <val2> 1 is returned, otherwise
|
||||||
|
0 is returned.
|
||||||
|
|
||||||
|
@(>,<val1>,<val2>)
|
||||||
|
If the number <val1> is greater than <val2> 1 is returned,
|
||||||
|
otherwise 0 is returned.
|
||||||
|
|
||||||
|
@(!=,<val1>,<val2>)
|
||||||
|
If the numbers <val1> and <val2> are not equal 1 is returned,
|
||||||
|
otherwise 0 is returned.
|
||||||
|
|
||||||
|
@(<=,<val1>,<val2>)
|
||||||
|
If the number <val1> is less than or equal to <val2> 1 is
|
||||||
|
returned, otherwise 0 is returned.
|
||||||
|
|
||||||
|
@(>=,<val1>,<val2>)
|
||||||
|
If the number <val1> is greater than or equal to <val2> 1 is
|
||||||
|
returned, otherwise 0 is returned.
|
||||||
|
|
||||||
|
@(AND,<val1>,<val2>,...<valn>)
|
||||||
|
The bitwise logical AND of the integers <val1> through <valn> is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
@(EQ,<val1>,<val2>)
|
||||||
|
If the strings <val1> and <val2> are identical 1 is returned,
|
||||||
|
otherwise 0.
|
||||||
|
|
||||||
|
@(EVAL,<str>)
|
||||||
|
The string <str> is passed to the DIESEL evaluator and the result
|
||||||
|
of evaluating it is returned.
|
||||||
|
|
||||||
|
@(FIX,<value>)
|
||||||
|
The real number <value> is truncated to an integer by discarding
|
||||||
|
any fractional part.
|
||||||
|
|
||||||
|
@(IF,<expr>,<dotrue>,<dofalse>)
|
||||||
|
If <expr> is nonzero, <dotrue> is evaluated and returned.
|
||||||
|
Otherwise, <dofalse> is evaluated and returned. Note that the
|
||||||
|
branch not chosen by <expr> is not evaluated.
|
||||||
|
|
||||||
|
@(INDEX,<which>,<string>)
|
||||||
|
<string> is assumed to contain one or more values delimited by the
|
||||||
|
macro argument separator character, comma. <which> selects one of
|
||||||
|
these values to be extracted, with the first item numbered zero.
|
||||||
|
|
||||||
|
* @(LOWER,<string>)
|
||||||
|
The <string> is returned converted to lower case according to the
|
||||||
|
rules of the current locale.
|
||||||
|
|
||||||
|
@(NTH,<which>,<arg0>,<arg1>,<argN>)
|
||||||
|
Evaluates and returns the argument selected by <which>. If
|
||||||
|
<which> is 0, <arg0> is returned, and so on. Note the difference
|
||||||
|
between @(NTH) and @(INDEX); @(NTH) returns one of a series of
|
||||||
|
arguments to the function while @(INDEX) extracts a value from a
|
||||||
|
comma-delimited string passed as a single argument. Arguments not
|
||||||
|
selected by <which> are not evaluated.
|
||||||
|
|
||||||
|
@(OR,<val1>,<val2>,...<valn>)
|
||||||
|
The bitwise logical OR of the integers <val1> through <valn> is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
* @(STRCMP,<str1>,<str2>)
|
||||||
|
Compare strings and returns -1 if <str1> is less than <Str2>, 0 if
|
||||||
|
both are equals, or 1 if <str1> is greater than <str2> .
|
||||||
|
|
||||||
|
@(STRFILL,<string>,<ncopies>)
|
||||||
|
Returns the result of concatenating <ncopies> of <string>.
|
||||||
|
|
||||||
|
@(STRLEN,<string>)
|
||||||
|
Returns the length of <string> in characters.
|
||||||
|
|
||||||
|
* @(STRSTR,<str1>,<str2>)
|
||||||
|
Find first apparition of <str2> in <str1>, and return the position
|
||||||
|
or 0 if not found.
|
||||||
|
|
||||||
|
@(SUBSTR,<string>,<start>,<length>)
|
||||||
|
Returns the substring of <string> starting at character <start>
|
||||||
|
and extending for <length> characters. Characters in the string
|
||||||
|
are numbered from 1. If <length> is omitted, the entire remaining
|
||||||
|
length of the string is returned.
|
||||||
|
|
||||||
|
@(UPPER,<string>)
|
||||||
|
The <string> is returned converted to upper case according to the
|
||||||
|
rules of the current locale.
|
||||||
|
|
||||||
|
@(XOR,<val1>,<val2>,...<valn>)
|
||||||
|
The bitwise logical XOR of the integers <val1> through <valn> is
|
||||||
|
returned.
|
||||||
|
|
||||||
|
Variable Extensions
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
The base-line DIESEL includes no user-defined variables. This allows
|
||||||
|
DIESEL to avoid allocating any local memory and renders it totally
|
||||||
|
reentrant. If you compile DIESEL with the tag VARIABLES defined, the
|
||||||
|
following additional functions are included which provide variable
|
||||||
|
definition and access. Note that these functions call malloc() and
|
||||||
|
strdup() and thus consume heap storage.
|
||||||
|
|
||||||
|
Variable names are case sensitive.
|
||||||
|
|
||||||
|
If you want easily format output you must use one-char variable names
|
||||||
|
then you can format output as @V_____, @X_____< or @k___>. See above.
|
||||||
|
|
||||||
|
@(GETVAR,varname)
|
||||||
|
Returns the value stored in <varname>. If no variable with
|
||||||
|
the name <varname> exists, a bad argument error is reported.
|
||||||
|
|
||||||
|
@(SETVAR,varname,value)
|
||||||
|
Stores the string <value> into <varname>. If no variable
|
||||||
|
called <varname> exists, a new variable is created.
|
||||||
|
|
||||||
|
* @(CLEAR)
|
||||||
|
Clear all variables.
|
||||||
|
|
||||||
|
Unix Extensions
|
||||||
|
---------------
|
||||||
|
|
||||||
|
If you compile DIESEL with the tag UNIXTENSIONS defined, the following
|
||||||
|
additional functions will be available:
|
||||||
|
|
||||||
|
@(GETENV,varname)
|
||||||
|
Returns the variable <varname> from the environment. If no such
|
||||||
|
variable is defined, returns the null string.
|
||||||
|
|
||||||
|
@(TIME)
|
||||||
|
Returns the current time in Unix fashion, as the number of seconds
|
||||||
|
elapsed since 00:00:00 GMT January 1, 1970.
|
||||||
|
|
||||||
|
@(EDTIME,<time>,<picture>)
|
||||||
|
Edit the Unix time <time> to format <picture>. If <time> is 0,
|
||||||
|
the current date and time is edited (this is just shorthand for
|
||||||
|
the equivalent "@(EDTIME,@(TIME),<picture>)".).
|
||||||
|
|
||||||
|
Assume the date is: Thursday, 2 September 1993 4:53:17
|
||||||
|
|
||||||
|
Format phrases:
|
||||||
|
D 2
|
||||||
|
DD 02
|
||||||
|
DDD Thu
|
||||||
|
DDDD Thursday
|
||||||
|
M 9
|
||||||
|
MO 09
|
||||||
|
MON Sep
|
||||||
|
MONTH September
|
||||||
|
YY 93
|
||||||
|
YYYY 1993
|
||||||
|
H 4
|
||||||
|
HH 04
|
||||||
|
MM 53
|
||||||
|
SS 17
|
||||||
|
AM/PM AM
|
||||||
|
am/pm am
|
||||||
|
A/P A
|
||||||
|
a/p a
|
||||||
|
|
||||||
|
If any of the "AM/PM" phrases appear in the picture, the "H" and
|
||||||
|
"HH" phrases will edit the time according to the 12 hour civil
|
||||||
|
clock (12:00-12:59-1:00-11:59) instead of the 24 hour clock
|
||||||
|
(00:00-23:59).
|
||||||
|
|
||||||
|
TURBODIESEL Mechanics
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
Generally, if you mess something up in a DIESEL expression it's pretty
|
||||||
|
obvious what went wrong. DIESEL embeds an error indication in the
|
||||||
|
output stream depending on the nature of the error:
|
||||||
|
|
||||||
|
@? Syntax error (usually a missing right parenthesis
|
||||||
|
or runaway string).
|
||||||
|
|
||||||
|
@(<func>,??) Incorrect arguments to <func>.
|
||||||
|
|
||||||
|
@(<func>)?? Unknown function <func>.
|
||||||
|
|
||||||
|
@++ Output string too long--evaluation truncated.
|
||||||
|
|
||||||
|
|
||||||
|
Using TURBODIESEL
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
You invoke TURBODIESEL within your program by calling:
|
||||||
|
|
||||||
|
int status;
|
||||||
|
char instring[<whatever>], outstring[MAXSTR + 1];
|
||||||
|
|
||||||
|
outstring = ParseMacro(instring, &status);
|
||||||
|
|
||||||
|
The output from the evaluation will be stored in outstring when
|
||||||
|
control is returned to your program. If no errors were detected
|
||||||
|
during evaluation, status will be zero. Otherwise status gives the
|
||||||
|
character position within instring at which the error was detected.
|
||||||
|
If an error occurs, TURBODIESEL will include an error diagnostic,
|
||||||
|
documented above, in outstring.
|
||||||
|
|
||||||
|
To set single-char variables you can use:
|
||||||
|
|
||||||
|
MacroVars(<string-names>,<string-types>,<value1>,...,<valueN>);
|
||||||
|
|
||||||
|
string-names -> Variable names
|
||||||
|
string-types -> Variable types
|
||||||
|
(s: string, c: char, d: integer, f: float).
|
||||||
|
Both strings must be same lenght, and the number of values must
|
||||||
|
match with lenght and types.
|
||||||
|
|
||||||
|
Sample:
|
||||||
|
|
||||||
|
MacroVars("ABCDE","sscdf","A String","Another String",'C',5,4.67);
|
||||||
|
|
||||||
|
To clear all variables you can use:
|
||||||
|
|
||||||
|
MacroClear();
|
||||||
|
|
21
lib/Makefile
21
lib/Makefile
@ -27,15 +27,22 @@ MSGBASE_HDRS = jam.h jammsg.h jamsys.h msg.h msgtext.h
|
|||||||
MBINET_SRCS = nntp.c pop3.c smtp.c
|
MBINET_SRCS = nntp.c pop3.c smtp.c
|
||||||
MBINET_OBJS = nntp.o pop3.o smtp.o
|
MBINET_OBJS = nntp.o pop3.o smtp.o
|
||||||
MBINET_HDRS = mbinet.h
|
MBINET_HDRS = mbinet.h
|
||||||
|
DIESEL_SRSC = diesel.c mbdiesel.c
|
||||||
|
DIESEL_HDRS = diesel.h
|
||||||
|
DIESEL_OBJS = diesel.o mbdiesel.o
|
||||||
MEMWATCH_SRCS = memwatch.c
|
MEMWATCH_SRCS = memwatch.c
|
||||||
MEMWATCH_OBJS = memwatch.o
|
MEMWATCH_OBJS = memwatch.o
|
||||||
MEMWATCH_HDRS = memwatch.h
|
MEMWATCH_HDRS = memwatch.h
|
||||||
OTHER_HDRS = ansi.h bluewave.h libs.h mbse.h records.h structs.h users.h
|
OTHER_HDRS = ansi.h bluewave.h libs.h mbse.h records.h structs.h users.h
|
||||||
SRCS = ${CLCOMM_SRCS} ${COMMON_SRCS} ${DBASE_SRCS} ${MSGBASE_SRCS} ${MBINET_SRCS} ${MEMWATCH_SRCS}
|
SRCS = ${CLCOMM_SRCS} ${COMMON_SRCS} ${DBASE_SRCS} ${MSGBASE_SRCS} ${MBINET_SRCS} \
|
||||||
OBJS = ${CLCOMM_OBJS} ${COMMON_OBJS} ${DBASE_OBJS} ${MSGBASE_OBJS} ${MBINET_OBJS} ${MEMWATCH_OBJS}
|
${DIESEL_SRCS} ${MEMWATCH_SRCS}
|
||||||
HDRS = ${CLCOMM_HDRS} ${COMMON_HDRS} ${DBASE_HDRS} ${MSGBASE_HDRS} ${MBINET_HDRS} ${MEMWATCH_HDRS} ${OTHER_HDRS}
|
OBJS = ${CLCOMM_OBJS} ${COMMON_OBJS} ${DBASE_OBJS} ${MSGBASE_OBJS} ${MBINET_OBJS} \
|
||||||
OTHER = Makefile README ftscprod.006 mkprod.awk FAQ README.memwatch USING test.c memwatch.c.org
|
${DIESEL_OBJS} ${MEMWATCH_OBJS}
|
||||||
TARGET = libclcomm.a libcommon.a libdbase.a libmsgbase.a libmbinet.a libmemwatch.a
|
HDRS = ${CLCOMM_HDRS} ${COMMON_HDRS} ${DBASE_HDRS} ${MSGBASE_HDRS} ${MBINET_HDRS} \
|
||||||
|
${DIESEL_HDRS} ${MEMWATCH_HDRS} ${OTHER_HDRS}
|
||||||
|
OTHER = Makefile README ftscprod.006 mkprod.awk FAQ README.memwatch USING test.c \
|
||||||
|
memwatch.c.org README.diesel README.macro Diesel.doc
|
||||||
|
TARGET = libclcomm.a libcommon.a libdbase.a libmsgbase.a libmbinet.a libdiesel.a libmemwatch.a
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
@ -67,6 +74,10 @@ libmbinet.a: ${MBINET_OBJS}
|
|||||||
ar r $@ $?
|
ar r $@ $?
|
||||||
${RANLIB} $@
|
${RANLIB} $@
|
||||||
|
|
||||||
|
libdiesel.a: ${DIESEL_OBJS}
|
||||||
|
ar r $@ $?
|
||||||
|
${RANLIB} $@
|
||||||
|
|
||||||
libmemwatch.a: ${MEMWATCH_OBJS}
|
libmemwatch.a: ${MEMWATCH_OBJS}
|
||||||
ar r $@ $?
|
ar r $@ $?
|
||||||
${RANLIB} $@
|
${RANLIB} $@
|
||||||
|
20
lib/README.diesel
Normal file
20
lib/README.diesel
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
If you want compile a standalone diesel executable interpreter, you can
|
||||||
|
do it writing at linux prompt:
|
||||||
|
|
||||||
|
# cc -DTESTPROG -g diesel.c -o diesel
|
||||||
|
|
||||||
|
Then you can interpret a diesel script and see output calling...
|
||||||
|
|
||||||
|
# diesel <script
|
||||||
|
or...
|
||||||
|
# cat script |diesel
|
||||||
|
|
||||||
|
If you want set some vars before interpret script you can do...
|
||||||
|
|
||||||
|
# echo '@! @(setvar,a,5) @(setvar,B,HELLO)'| cat - script |diesel
|
||||||
|
|
||||||
|
Or you can put all @(setvar...) sentences in a separated file an call...
|
||||||
|
|
||||||
|
# cat setvar.file script |diesel
|
||||||
|
|
52
lib/README.macro
Normal file
52
lib/README.macro
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
Using turbodiesel macro files in mbse. Now you can personalize response
|
||||||
|
reports from areamgr, filemgr an notify using diesel macro files.
|
||||||
|
|
||||||
|
See diesel.doc for turbodiesel syntax.
|
||||||
|
|
||||||
|
Mbfido look for macro files first in macro language phat acording defined
|
||||||
|
language in nodes setup, and then in $MBSEROT/etc/. If no macro file found
|
||||||
|
mbfido uses harcoded respose.
|
||||||
|
|
||||||
|
(Michiel check that, I prefer not change CFG struct. If you add a default
|
||||||
|
macro path, you must change function OpenMacro in mgrutil.c at line 495)
|
||||||
|
|
||||||
|
Macro files used are:
|
||||||
|
|
||||||
|
areamgr.flow -> %FLOW
|
||||||
|
areamgr.group -> group report (included in areamgr.list)
|
||||||
|
areamgr.help -> %HELP
|
||||||
|
areamgr.list -> %LIST
|
||||||
|
areamgr.notify.flow -> Flow report sent by 'mbfido notify'
|
||||||
|
areamgr.notify.list -> Area status report sent by 'mbfido notify'
|
||||||
|
areamgr.query -> %QUERY
|
||||||
|
areamgr.responses -> Multiple responses for results of areamgr.
|
||||||
|
areamgr.status -> %STATUS
|
||||||
|
areamgr.unlink -> %UNLINK
|
||||||
|
|
||||||
|
filemgr.group -> group report (included in filemgr.list)
|
||||||
|
filemgr.help -> %HELP
|
||||||
|
filemgr.list -> %LIST
|
||||||
|
filemgr.notify.list -> Area status report sent by 'mbfido notify'
|
||||||
|
filemgr.query -> %QUERY
|
||||||
|
filemgr.responses -> Multiple responses for results of filemgr.
|
||||||
|
filemgr.status -> %STATUS
|
||||||
|
filemgr.unlink -> %UNLINK
|
||||||
|
|
||||||
|
Some files are very similar, and can be a symbolic link to other including a
|
||||||
|
few conditional macros.
|
||||||
|
|
||||||
|
See coments in sample files to undestand how work.
|
||||||
|
|
||||||
|
Overview
|
||||||
|
--------
|
||||||
|
|
||||||
|
For every macro file multiple values are passed in diesel variables,
|
||||||
|
see samples to know what variables can be used for each file.
|
||||||
|
|
||||||
|
If you assign a value to 'subject' variable in a macro file, then the
|
||||||
|
message subject will be that value.
|
||||||
|
|
||||||
|
Some files have multiple sections. Sections delimiter is @| at begin of line,
|
||||||
|
you can put a comentary after @| delimiter (see areamgr.list sample).
|
||||||
|
|
1932
lib/diesel.c
Normal file
1932
lib/diesel.c
Normal file
File diff suppressed because it is too large
Load Diff
54
lib/diesel.h
Normal file
54
lib/diesel.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef _DIESEL_H
|
||||||
|
#define _DIESEL_H
|
||||||
|
|
||||||
|
#define UNIXTENSIONS
|
||||||
|
#define VARIABLES
|
||||||
|
|
||||||
|
|
||||||
|
#define FALSE 0
|
||||||
|
#define TRUE 1
|
||||||
|
#define DIAGNOSTIC 2
|
||||||
|
|
||||||
|
#define EOS '\0'
|
||||||
|
|
||||||
|
#define V (void)
|
||||||
|
|
||||||
|
/* Globals exported */
|
||||||
|
|
||||||
|
#ifdef TRACE
|
||||||
|
int tracing = TRUE; /* Trace macro evalution */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Local variables. */
|
||||||
|
|
||||||
|
#define MAXARGS 10 /* Maximum arguments to a macro */
|
||||||
|
#define MAXSTR 256 /* Maximum string length */
|
||||||
|
#define MAXDEPTH 32 /* Maximum recursion depth for eval */
|
||||||
|
|
||||||
|
#define MACROCHAR '@' /* Macro trigger character */
|
||||||
|
#define ARGOPEN '(' /* Argument open bracket */
|
||||||
|
#define ARGCLOSE ')' /* Argument close bracket */
|
||||||
|
#define ARGSEP ',' /* Argument separator character */
|
||||||
|
#define QUOTE '"' /* Literal string quote character */
|
||||||
|
#define CASEINS /* Case-insensitive function names */
|
||||||
|
|
||||||
|
#define STRLIMIT (MAXSTR - 20) /* String output length limit */
|
||||||
|
#define OverFlow " @(++)" /* Glyph indicating string overflow */
|
||||||
|
|
||||||
|
#define ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
|
||||||
|
#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);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MBSE BBS specific functions
|
||||||
|
*/
|
||||||
|
FILE *OpenMacro(const char *, int);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
91
lib/mbdiesel.c
Normal file
91
lib/mbdiesel.c
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* Purpose ...............: MBSE BBS functions for TURBODIESEL
|
||||||
|
*
|
||||||
|
*****************************************************************************
|
||||||
|
* Copyright (C) 1997-2002
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "libs.h"
|
||||||
|
#include "structs.h"
|
||||||
|
#include "users.h"
|
||||||
|
#include "records.h"
|
||||||
|
#include "clcomm.h"
|
||||||
|
#include "diesel.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
FILE *OpenMacro(const char *filename, int Language)
|
||||||
|
{
|
||||||
|
FILE *pLang, *fi = NULL;
|
||||||
|
char *temp;
|
||||||
|
|
||||||
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
|
temp[0] = '\0';
|
||||||
|
|
||||||
|
if (Language != '\0') {
|
||||||
|
/*
|
||||||
|
* Maybe a valid language character, try to load the language
|
||||||
|
*/
|
||||||
|
sprintf(temp, "%s/etc/language.data", getenv("MBSE_ROOT"));
|
||||||
|
if ((pLang = fopen(temp, "rb")) == NULL) {
|
||||||
|
WriteError("mbdiesel: Can't open language file: %s", temp);
|
||||||
|
} else {
|
||||||
|
fread(&langhdr, sizeof(langhdr), 1, pLang);
|
||||||
|
|
||||||
|
while (fread(&lang, langhdr.recsize, 1, pLang) == 1) {
|
||||||
|
if ((lang.LangKey[0] == Language) && (lang.Available)) {
|
||||||
|
sprintf(temp,"%s/%s", lang.MacroPath, filename);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(pLang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try to open the selected language
|
||||||
|
*/
|
||||||
|
if (temp[0] != '\0')
|
||||||
|
fi = fopen(temp, "r");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If no selected language is loaded, try default language
|
||||||
|
*/
|
||||||
|
if (fi == NULL) {
|
||||||
|
sprintf(temp, "%s/%s", CFG.bbs_macros, filename);
|
||||||
|
fi = fopen(temp,"r");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fi == NULL)
|
||||||
|
Syslog('d', "OpenMacro(%s, %c): not found, using hardcoded", filename, Language);
|
||||||
|
else
|
||||||
|
Syslog('d', "OpenMacro(%s, %c): using %s", filename, Language, temp);
|
||||||
|
|
||||||
|
free(temp);
|
||||||
|
return fi;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ MBFILE_OBJS = mbfile.o mbfkill.o mbfutil.o mbfindex.o mbfcheck.o mbfpack.o mbfli
|
|||||||
mbfimport.o virscan.o mbftoberep.o mbfmove.o mbfdel.o
|
mbfimport.o virscan.o mbftoberep.o mbfmove.o mbfdel.o
|
||||||
MBMSG_OBJS = post.o mbmsg.o
|
MBMSG_OBJS = post.o mbmsg.o
|
||||||
MBFIDO_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
|
MBFIDO_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a \
|
||||||
../lib/libdbase.a ../lib/libmbinet.a
|
../lib/libdbase.a ../lib/libdiesel.a ../lib/libmbinet.a
|
||||||
MBSEQ_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.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
|
||||||
MBINDEX_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
|
MBINDEX_LIBS = ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libdbase.a
|
||||||
|
691
mbfido/areamgr.c
691
mbfido/areamgr.c
File diff suppressed because it is too large
Load Diff
559
mbfido/filemgr.c
559
mbfido/filemgr.c
@ -42,10 +42,15 @@
|
|||||||
#include "../lib/dbdupe.h"
|
#include "../lib/dbdupe.h"
|
||||||
#include "../lib/dbuser.h"
|
#include "../lib/dbuser.h"
|
||||||
#include "../lib/dbftn.h"
|
#include "../lib/dbftn.h"
|
||||||
|
#include "../lib/diesel.h"
|
||||||
#include "sendmail.h"
|
#include "sendmail.h"
|
||||||
#include "mgrutil.h"
|
#include "mgrutil.h"
|
||||||
#include "filemgr.h"
|
#include "filemgr.h"
|
||||||
|
|
||||||
|
#define LIST_LIST 0
|
||||||
|
#define LIST_NOTIFY 1
|
||||||
|
#define LIST_QUERY 2
|
||||||
|
#define LIST_UNLINK 3
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -72,11 +77,27 @@ int f_unlnk = FALSE; /* Send FileMgr unlink */
|
|||||||
void F_Help(faddr *, char *);
|
void F_Help(faddr *, char *);
|
||||||
void F_Help(faddr *t, char *replyid)
|
void F_Help(faddr *t, char *replyid)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp, *fi;
|
||||||
|
char *line,*subject;
|
||||||
|
int res;
|
||||||
|
|
||||||
Syslog('+', "FileMgr: Help");
|
Syslog('+', "FileMgr: Help");
|
||||||
|
subject=calloc(255,sizeof(char));
|
||||||
|
sprintf(subject,"FileMgr help");
|
||||||
|
MacroVars("SsNAP", "sssss", CFG.sysop_name, nodes.Sysop, (char *)"Filemgr", ascfnode(bestaka_s(t), 0xf), nodes.Fpasswd );
|
||||||
|
GetRpSubject("filemgr.help",subject);
|
||||||
|
|
||||||
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr help", replyid)) != NULL) {
|
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));
|
||||||
|
}
|
||||||
|
MacroClear();
|
||||||
|
free(line);
|
||||||
|
fclose(fi);
|
||||||
|
}else{
|
||||||
fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Filemgr");
|
fprintf(fp, "Address all requests to '%s' (without quotes)\r", (char *)"Filemgr");
|
||||||
fprintf(fp, "Your FileMgr password goes on the subject line.\r\r");
|
fprintf(fp, "Your FileMgr password goes on the subject line.\r\r");
|
||||||
|
|
||||||
@ -115,11 +136,12 @@ void F_Help(faddr *t, char *replyid)
|
|||||||
fprintf(fp, " -NODELIST\r");
|
fprintf(fp, " -NODELIST\r");
|
||||||
fprintf(fp, " %%QUERY\r");
|
fprintf(fp, " %%QUERY\r");
|
||||||
fprintf(fp, " %%LIST\r\r");
|
fprintf(fp, " %%LIST\r\r");
|
||||||
|
}
|
||||||
fprintf(fp, "%s\r", TearLine());
|
fprintf(fp, "%s\r", TearLine());
|
||||||
CloseMail(fp, t);
|
CloseMail(fp, t);
|
||||||
} else
|
} else
|
||||||
WriteError("Can't create netmail");
|
WriteError("Can't create netmail");
|
||||||
|
free(subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,156 +149,89 @@ void F_Help(faddr *t, char *replyid)
|
|||||||
void F_Query(faddr *, char *);
|
void F_Query(faddr *, char *);
|
||||||
void F_Query(faddr *t, char *replyid)
|
void F_Query(faddr *t, char *replyid)
|
||||||
{
|
{
|
||||||
FILE *qp, *gp, *fp;
|
F_List(t, replyid, LIST_QUERY);
|
||||||
char *temp, *Group;
|
|
||||||
int i, First = TRUE, SubTot, Total = 0, Cons;
|
|
||||||
char Stat[4];
|
|
||||||
faddr *f, *g;
|
|
||||||
sysconnect System;
|
|
||||||
long msgptr;
|
|
||||||
|
|
||||||
Syslog('+', "FileMgr: Query");
|
|
||||||
f = bestaka_s(t);
|
|
||||||
Syslog('f', "Bestaka for %s is %s", ascfnode(t, 0x0f), ascfnode(f, 0x0f));
|
|
||||||
|
|
||||||
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your query request", replyid)) != NULL) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mark begin of message in .pkt
|
|
||||||
*/
|
|
||||||
msgptr = ftell(qp);
|
|
||||||
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
|
||||||
WriteError("$Can't open %s", temp);
|
|
||||||
free(temp);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
fread(&tichdr, sizeof(tichdr), 1, fp);
|
|
||||||
Cons = tichdr.syssize / sizeof(System);
|
|
||||||
|
|
||||||
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
||||||
if ((gp = fopen(temp, "r")) == NULL) {
|
|
||||||
WriteError("$Can't open %s", temp);
|
|
||||||
free(temp);
|
|
||||||
fclose(fp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
|
||||||
free(temp);
|
|
||||||
|
|
||||||
fprintf(qp, "The following is a list of all connected file areas\r\r");
|
|
||||||
|
|
||||||
while (TRUE) {
|
|
||||||
Group = GetNodeFileGrp(First);
|
|
||||||
if (Group == NULL)
|
|
||||||
break;
|
|
||||||
First = FALSE;
|
|
||||||
|
|
||||||
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
|
|
||||||
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
|
|
||||||
g = bestaka_s(fido2faddr(fgroup.UseAka));
|
|
||||||
if ((!strcmp(fgroup.Name, Group)) &&
|
|
||||||
(g->zone == f->zone) && (g->net == f->net) &&
|
|
||||||
(g->node == f->node) && (g->point == f->point)) {
|
|
||||||
Syslog('f', "Group %s, aka %s", fgroup.Name, aka2str(fgroup.UseAka));
|
|
||||||
SubTot = 0;
|
|
||||||
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
|
|
||||||
fprintf(qp, "Con File tic Description\r");
|
|
||||||
fprintf(qp, "------------------------------------------------------------------------\r");
|
|
||||||
fseek(fp, tichdr.hdrsize, SEEK_SET);
|
|
||||||
|
|
||||||
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
|
|
||||||
if (!strcmp(Group, tic.Group) && tic.Active) {
|
|
||||||
memset(&Stat, ' ', sizeof(Stat));
|
|
||||||
Stat[sizeof(Stat)-1] = '\0';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now check if this node is connected,
|
|
||||||
* if so, set the Stat bits.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < Cons; i++) {
|
|
||||||
fread(&System, sizeof(System), 1, fp);
|
|
||||||
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
|
|
||||||
(t->node == System.aka.node) && (t->point == System.aka.point)) {
|
|
||||||
if (System.receivefrom)
|
|
||||||
Stat[0] = 'S';
|
|
||||||
if (System.sendto)
|
|
||||||
Stat[1] = 'R';
|
|
||||||
if (System.pause)
|
|
||||||
Stat[2] = 'P';
|
|
||||||
|
|
||||||
if (System.sendto || System.receivefrom) {
|
|
||||||
fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment);
|
|
||||||
SubTot++;
|
|
||||||
Total++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
fseek(fp, tichdr.syssize, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(qp, "------------------------------------------------------------------------\r");
|
|
||||||
fprintf(qp, "%d available area(s)\r\r\r", SubTot);
|
|
||||||
|
|
||||||
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
|
|
||||||
fprintf(qp, "To be continued....\r\r");
|
|
||||||
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
|
|
||||||
CloseMail(qp, t);
|
|
||||||
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your query request", replyid);
|
|
||||||
msgptr = ftell(qp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
fclose(gp);
|
|
||||||
|
|
||||||
fprintf(qp, "Con means:\r");
|
|
||||||
fprintf(qp, " R - You receive files from my system\r");
|
|
||||||
fprintf(qp, " S - You may send files in this area\r");
|
|
||||||
fprintf(qp, " P - The file area is temporary paused\r\r");
|
|
||||||
fprintf(qp, "With regards, %s\r\r", CFG.sysop_name);
|
|
||||||
fprintf(qp, "%s\r", TearLine());
|
|
||||||
CloseMail(qp, t);
|
|
||||||
} else
|
|
||||||
WriteError("Can't create netmail");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void F_List(faddr *t, char *replyid, int Notify)
|
void F_List(faddr *t, char *replyid, int Notify)
|
||||||
{
|
{
|
||||||
FILE *qp, *gp, *fp;
|
FILE *qp, *gp, *fp, *fi;
|
||||||
char *temp, *Group;
|
char *temp, *Group, *line, *subject;
|
||||||
int i, First = TRUE, SubTot, Total = 0, Cons;
|
int i, First = TRUE, SubTot, Total = 0, Cons, res;
|
||||||
char Stat[4];
|
char Stat[4];
|
||||||
faddr *f, *g;
|
faddr *f, *g;
|
||||||
sysconnect System;
|
sysconnect System;
|
||||||
long msgptr;
|
long msgptr;
|
||||||
|
fpos_t fileptr,fileptr1,fileptr2;
|
||||||
|
|
||||||
if (Notify)
|
subject = calloc(255, sizeof(char));
|
||||||
|
|
||||||
|
MacroVars("SsKyY", "ssdss",
|
||||||
|
CFG.sysop_name,
|
||||||
|
nodes.Sysop,
|
||||||
|
Notify,
|
||||||
|
ascfnode(t, 0xff),
|
||||||
|
ascfnode(bestaka_s(t), 0xf)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (Notify==LIST_NOTIFY){
|
||||||
Syslog('+', "FileMgr: Notify to %s", ascfnode(t, 0xff));
|
Syslog('+', "FileMgr: Notify to %s", ascfnode(t, 0xff));
|
||||||
else
|
sprintf(subject,"FileMgr Notify");
|
||||||
|
GetRpSubject("filemgr.notify.list",subject);
|
||||||
|
}
|
||||||
|
if (Notify==LIST_LIST){
|
||||||
Syslog('+', "FileMgr: List");
|
Syslog('+', "FileMgr: List");
|
||||||
|
sprintf(subject,"FileMgr list");
|
||||||
|
GetRpSubject("filemgr.list",subject);
|
||||||
|
}
|
||||||
|
if (Notify==LIST_QUERY){
|
||||||
|
Syslog('+', "FileMgr: Query");
|
||||||
|
sprintf(subject,"FileMgr Query");
|
||||||
|
GetRpSubject("filemgr.query",subject);
|
||||||
|
}
|
||||||
|
if (Notify>=LIST_UNLINK){
|
||||||
|
Syslog('+', "FileMgr: Unlinked");
|
||||||
|
sprintf(subject,"FileMgr: Unlinked areas");
|
||||||
|
GetRpSubject("filemgr.unlink",subject);
|
||||||
|
}
|
||||||
f = bestaka_s(t);
|
f = bestaka_s(t);
|
||||||
|
|
||||||
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid)) != NULL) {
|
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mark begin of message in .pkt
|
* Mark begin of message in .pkt
|
||||||
*/
|
*/
|
||||||
msgptr = ftell(qp);
|
msgptr = ftell(qp);
|
||||||
WriteFileGroups(qp, f);
|
|
||||||
|
|
||||||
|
fi=NULL;
|
||||||
|
if (Notify==LIST_LIST){
|
||||||
|
fi=OpenMacro("filemgr.list", nodes.Language);
|
||||||
|
WriteFileGroups(qp, f);
|
||||||
|
}
|
||||||
|
if (Notify==LIST_NOTIFY){
|
||||||
|
fi=OpenMacro("filemgr.notify.list", nodes.Language);
|
||||||
|
WriteFileGroups(qp, f);
|
||||||
|
}
|
||||||
|
if (Notify==LIST_QUERY)
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
fgetpos(fi,&fileptr);
|
||||||
|
}else{
|
||||||
|
fprintf(qp, "The following is a list of file areas\r\r");
|
||||||
|
}
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
temp = calloc(PATH_MAX, sizeof(char));
|
||||||
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
if ((fp = fopen(temp, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", temp);
|
WriteError("$Can't open %s", temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
free(line);
|
||||||
|
free(subject);
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fread(&tichdr, sizeof(tichdr), 1, fp);
|
fread(&tichdr, sizeof(tichdr), 1, fp);
|
||||||
@ -286,14 +241,15 @@ void F_List(faddr *t, char *replyid, int Notify)
|
|||||||
if ((gp = fopen(temp, "r")) == NULL) {
|
if ((gp = fopen(temp, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", temp);
|
WriteError("$Can't open %s", temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
free(line);
|
||||||
|
free(subject);
|
||||||
|
MacroClear();
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
||||||
free(temp);
|
free(temp);
|
||||||
|
|
||||||
fprintf(qp, "The following is a list of all file areas\r\r");
|
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
Group = GetNodeFileGrp(First);
|
Group = GetNodeFileGrp(First);
|
||||||
if (Group == NULL)
|
if (Group == NULL)
|
||||||
@ -307,9 +263,18 @@ void F_List(faddr *t, char *replyid, int Notify)
|
|||||||
(g->zone == f->zone) && (g->net == f->net) &&
|
(g->zone == f->zone) && (g->net == f->net) &&
|
||||||
(g->node == f->node) && (g->point == f->point)) {
|
(g->node == f->node) && (g->point == f->point)) {
|
||||||
SubTot = 0;
|
SubTot = 0;
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
fgetpos(fi,&fileptr1);
|
||||||
|
}else{
|
||||||
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
|
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
|
||||||
fprintf(qp, "Con File tic Description\r");
|
fprintf(qp, "Con File tic Description\r");
|
||||||
fprintf(qp, "------------------------------------------------------------------------\r");
|
fprintf(qp, "------------------------------------------------------------------------\r");
|
||||||
|
}
|
||||||
fseek(fp, tichdr.hdrsize, SEEK_SET);
|
fseek(fp, tichdr.hdrsize, SEEK_SET);
|
||||||
|
|
||||||
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
|
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
|
||||||
@ -332,13 +297,45 @@ void F_List(faddr *t, char *replyid, int Notify)
|
|||||||
Stat[2] = 'P';
|
Stat[2] = 'P';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( (Notify == LIST_LIST)
|
||||||
|
|| (Notify == LIST_NOTIFY)
|
||||||
|
|| ((Notify == LIST_QUERY) && ((Stat[0]=='S') || (Stat[1]=='R')))
|
||||||
|
|| ((Notify >= LIST_UNLINK) && ((Stat[0]!='S') && (Stat[1]!='R')))){
|
||||||
|
if (fi !=NULL){
|
||||||
|
MacroVars("XTNsrp", "sssddd",
|
||||||
|
Stat, tic.Name, tic.Comment,
|
||||||
|
(Stat[0] == 'S'),
|
||||||
|
(Stat[1] == 'R'),
|
||||||
|
(Stat[2] == 'P')
|
||||||
|
);
|
||||||
|
fsetpos(fi,&fileptr1);
|
||||||
|
while ( (fgets(line, 254, fi) != NULL) && ((line[0]!='@') || (line[1]!='|'))){
|
||||||
|
fprintf( qp, "%s", ParseMacro(line,&res));
|
||||||
|
}
|
||||||
|
fgetpos(fi,&fileptr2);
|
||||||
|
}else{
|
||||||
fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment);
|
fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment);
|
||||||
|
}
|
||||||
SubTot++;
|
SubTot++;
|
||||||
Total++;
|
Total++;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
fseek(fp, tichdr.syssize, SEEK_CUR);
|
fseek(fp, tichdr.syssize, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
fprintf(qp, "------------------------------------------------------------------------\r");
|
fprintf(qp, "------------------------------------------------------------------------\r");
|
||||||
fprintf(qp, "%d available area(s)\r\r\r", SubTot);
|
fprintf(qp, "%d available area(s)\r\r\r", SubTot);
|
||||||
|
|
||||||
@ -346,25 +343,39 @@ void F_List(faddr *t, char *replyid, int Notify)
|
|||||||
fprintf(qp, "To be continued....\r\r");
|
fprintf(qp, "To be continued....\r\r");
|
||||||
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
|
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
|
||||||
CloseMail(qp, t);
|
CloseMail(qp, t);
|
||||||
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr List", replyid);
|
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid);
|
||||||
msgptr = ftell(qp);
|
msgptr = ftell(qp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fclose(fp);
|
if (fi != NULL){
|
||||||
fclose(gp);
|
MacroVars("B", "d", Total );
|
||||||
|
while ( fgets(line, 254, fi) != NULL ){
|
||||||
|
fprintf( qp, "%s", ParseMacro(line,&res));
|
||||||
|
}
|
||||||
|
MacroClear();
|
||||||
|
fclose(fi);
|
||||||
|
}else{
|
||||||
|
fprintf(qp, "Total: %d available area(s)\r\r\r", Total);
|
||||||
|
|
||||||
fprintf(qp, "Con means:\r");
|
fprintf(qp, "Con means:\r");
|
||||||
fprintf(qp, " R - You receive files from my system\r");
|
fprintf(qp, " R - You receive files from my system\r");
|
||||||
fprintf(qp, " S - You may send files in this area\r");
|
fprintf(qp, " S - You may send files in this area\r");
|
||||||
fprintf(qp, " P - The file area is temporary paused\r\r");
|
fprintf(qp, " P - The file area is temporary paused\r\r");
|
||||||
fprintf(qp, "With regards, %s\r\r", CFG.sysop_name);
|
fprintf(qp, "With regards, %s\r\r", CFG.sysop_name);
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
fclose(gp);
|
||||||
|
free(line);
|
||||||
fprintf(qp, "%s\r", TearLine());
|
fprintf(qp, "%s\r", TearLine());
|
||||||
CloseMail(qp, t);
|
CloseMail(qp, t);
|
||||||
} else
|
} else
|
||||||
WriteError("Can't create netmail");
|
WriteError("Can't create netmail");
|
||||||
|
free(subject);
|
||||||
|
MacroClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -372,17 +383,55 @@ void F_List(faddr *t, char *replyid, int Notify)
|
|||||||
void F_Status(faddr *, char *);
|
void F_Status(faddr *, char *);
|
||||||
void F_Status(faddr *t, char *replyid)
|
void F_Status(faddr *t, char *replyid)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp, *fi;
|
||||||
int i;
|
int i,res;
|
||||||
|
char *line,*subject;
|
||||||
|
|
||||||
|
subject = calloc(255, sizeof(char));
|
||||||
|
sprintf(subject,"FileMgr Status");
|
||||||
Syslog('+', "FileMgr: Status");
|
Syslog('+', "FileMgr: Status");
|
||||||
if (Miy == 0)
|
if (Miy == 0)
|
||||||
i = 11;
|
i = 11;
|
||||||
else
|
else
|
||||||
i = Miy - 1;
|
i = Miy - 1;
|
||||||
|
MacroVars("MTANBDECWabcdefghijklSs", "dddddddddddddddddddddss",
|
||||||
|
nodes.Message,
|
||||||
|
nodes.Tic,
|
||||||
|
nodes.AdvTic,
|
||||||
|
nodes.Notify,
|
||||||
|
nodes.Billing,
|
||||||
|
nodes.BillDirect,
|
||||||
|
nodes.Debet,
|
||||||
|
nodes.Credit,
|
||||||
|
nodes.WarnLevel,
|
||||||
|
nodes.FilesSent.lweek,
|
||||||
|
nodes.FilesSent.month[i],
|
||||||
|
nodes.FilesSent.total,
|
||||||
|
nodes.F_KbSent.lweek,
|
||||||
|
nodes.F_KbSent.month[i],
|
||||||
|
nodes.F_KbSent.total,
|
||||||
|
nodes.FilesRcvd.lweek,
|
||||||
|
nodes.FilesRcvd.month[i],
|
||||||
|
nodes.FilesRcvd.total,
|
||||||
|
nodes.F_KbRcvd.lweek,
|
||||||
|
nodes.F_KbRcvd.month[i],
|
||||||
|
nodes.F_KbRcvd.total,
|
||||||
|
CFG.sysop_name,
|
||||||
|
nodes.Sysop
|
||||||
|
);
|
||||||
|
GetRpSubject("filemgr.status",subject);
|
||||||
|
|
||||||
if ((fp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"FileMgr Status", replyid)) != NULL) {
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
MacroClear();
|
||||||
|
free(line);
|
||||||
|
fclose(fi);
|
||||||
|
}else{
|
||||||
fprintf(fp, "Here is your fileecho status:\r\r");
|
fprintf(fp, "Here is your fileecho status:\r\r");
|
||||||
|
|
||||||
fprintf(fp, "Netmail message %s\r", GetBool(nodes.Message));
|
fprintf(fp, "Netmail message %s\r", GetBool(nodes.Message));
|
||||||
@ -412,11 +461,13 @@ void F_Status(faddr *t, char *replyid)
|
|||||||
nodes.F_KbRcvd.month[i], nodes.F_KbRcvd.total);
|
nodes.F_KbRcvd.month[i], nodes.F_KbRcvd.total);
|
||||||
|
|
||||||
fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name);
|
fprintf(fp, "\rWith regards, %s\r\r", CFG.sysop_name);
|
||||||
|
}
|
||||||
fprintf(fp, "%s\r", TearLine());
|
fprintf(fp, "%s\r", TearLine());
|
||||||
CloseMail(fp, t);
|
CloseMail(fp, t);
|
||||||
} else
|
} else
|
||||||
WriteError("Can't create netmail");
|
WriteError("Can't create netmail");
|
||||||
|
MacroClear();
|
||||||
|
free(subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -424,119 +475,7 @@ void F_Status(faddr *t, char *replyid)
|
|||||||
void F_Unlinked(faddr *, char *);
|
void F_Unlinked(faddr *, char *);
|
||||||
void F_Unlinked(faddr *t, char *replyid)
|
void F_Unlinked(faddr *t, char *replyid)
|
||||||
{
|
{
|
||||||
FILE *qp, *gp, *fp;
|
F_List(t, replyid, LIST_UNLINK);
|
||||||
char *temp, *Group;
|
|
||||||
int i, First = TRUE, SubTot, Total = 0, Cons;
|
|
||||||
char Stat[4];
|
|
||||||
faddr *f, *g;
|
|
||||||
sysconnect System;
|
|
||||||
long msgptr;
|
|
||||||
|
|
||||||
Syslog('+', "FileMgr: Unlinked");
|
|
||||||
f = bestaka_s(t);
|
|
||||||
|
|
||||||
if ((qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your unlinked request", replyid)) != NULL) {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Mark begin of message in .pkt
|
|
||||||
*/
|
|
||||||
msgptr = ftell(qp);
|
|
||||||
temp = calloc(PATH_MAX, sizeof(char));
|
|
||||||
sprintf(temp, "%s/etc/tic.data", getenv("MBSE_ROOT"));
|
|
||||||
if ((fp = fopen(temp, "r")) == NULL) {
|
|
||||||
WriteError("$Can't open %s", temp);
|
|
||||||
free(temp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fread(&tichdr, sizeof(tichdr), 1, fp);
|
|
||||||
Cons = tichdr.syssize / sizeof(System);
|
|
||||||
|
|
||||||
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
|
||||||
if ((gp = fopen(temp, "r")) == NULL) {
|
|
||||||
WriteError("$Can't open %s", temp);
|
|
||||||
free(temp);
|
|
||||||
fclose(fp);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
|
||||||
free(temp);
|
|
||||||
|
|
||||||
fprintf(qp, "The following is a list of all available file areas\r\r");
|
|
||||||
|
|
||||||
while (TRUE) {
|
|
||||||
Group = GetNodeFileGrp(First);
|
|
||||||
if (Group == NULL)
|
|
||||||
break;
|
|
||||||
First = FALSE;
|
|
||||||
|
|
||||||
fseek(gp, fgrouphdr.hdrsize, SEEK_SET);
|
|
||||||
while (fread(&fgroup, fgrouphdr.recsize, 1, gp) == 1) {
|
|
||||||
g = bestaka_s(fido2faddr(fgroup.UseAka));
|
|
||||||
if ((!strcmp(fgroup.Name, Group)) &&
|
|
||||||
(g->zone == f->zone) && (g->net == f->net) &&
|
|
||||||
(g->node == f->node) && (g->point == f->point)) {
|
|
||||||
SubTot = 0;
|
|
||||||
fprintf(qp, "Group %s - %s (%s)\r\r", fgroup.Name, fgroup.Comment, aka2str(fgroup.UseAka));
|
|
||||||
fprintf(qp, "Con File tic Description\r");
|
|
||||||
fprintf(qp, "------------------------------------------------------------------------\r");
|
|
||||||
fseek(fp, tichdr.hdrsize, SEEK_SET);
|
|
||||||
|
|
||||||
while (fread(&tic, tichdr.recsize, 1, fp) == 1) {
|
|
||||||
if (!strcmp(Group, tic.Group) && tic.Active) {
|
|
||||||
memset(&Stat, ' ', sizeof(Stat));
|
|
||||||
Stat[sizeof(Stat)-1] = '\0';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Now check if this node is connected, if so, set the Stat bits.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < Cons; i++) {
|
|
||||||
fread(&System, sizeof(System), 1, fp);
|
|
||||||
if ((t->zone == System.aka.zone) && (t->net == System.aka.net) &&
|
|
||||||
(t->node == System.aka.node) && (t->point == System.aka.point)) {
|
|
||||||
if (System.receivefrom)
|
|
||||||
Stat[0] = 'S';
|
|
||||||
if (System.sendto)
|
|
||||||
Stat[1] = 'R';
|
|
||||||
if (System.pause)
|
|
||||||
Stat[2] = 'P';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((!System.sendto) && (!System.receivefrom)) {
|
|
||||||
fprintf(qp, "%s %-20s %s\r", Stat, tic.Name, tic.Comment);
|
|
||||||
SubTot++;
|
|
||||||
Total++;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
fseek(fp, tichdr.syssize, SEEK_CUR);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(qp, "------------------------------------------------------------------------\r");
|
|
||||||
fprintf(qp, "%d available area(s)\r\r\r", SubTot);
|
|
||||||
|
|
||||||
if (((ftell(qp) - msgptr) / 1024) >= CFG.new_split) {
|
|
||||||
fprintf(qp, "To be continued....\r\r");
|
|
||||||
Syslog('-', " Splitting message at %ld bytes", ftell(qp) - msgptr);
|
|
||||||
CloseMail(qp, t);
|
|
||||||
qp = SendMgrMail(t, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your unlinked request", replyid);
|
|
||||||
msgptr = ftell(qp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
fclose(gp);
|
|
||||||
|
|
||||||
fprintf(qp, "Con means:\r");
|
|
||||||
fprintf(qp, " R - You receive files from my system\r");
|
|
||||||
fprintf(qp, " S - You may send files in this area\r");
|
|
||||||
fprintf(qp, " P - The file area is temporary paused\r\r");
|
|
||||||
fprintf(qp, "With regards, %s\r\r", CFG.sysop_name);
|
|
||||||
fprintf(qp, "%s\r", TearLine());
|
|
||||||
CloseMail(qp, t);
|
|
||||||
} else
|
|
||||||
WriteError("Can't create netmail");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -555,8 +494,12 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
|
|||||||
Area[i] = toupper(Area[i]);
|
Area[i] = toupper(Area[i]);
|
||||||
|
|
||||||
if (!SearchTic(Area)) {
|
if (!SearchTic(Area)) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTFOUND",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Area %s not found\n", Area);
|
fprintf(tmp, "Area %s not found\n", Area);
|
||||||
Syslog('+', " Area not found");
|
Syslog('+', " Area not found");
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -569,8 +512,12 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Group == NULL) {
|
if (Group == NULL) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTGROUP",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You may not disconnect from area %s\n", Area);
|
fprintf(tmp, "You may not disconnect from area %s\n", Area);
|
||||||
Syslog('+', " Group %s not available for %s", fgroup.Name, ascfnode(t, 0x1f));
|
Syslog('+', " Group %s not available for %s", fgroup.Name, ascfnode(t, 0x1f));
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,8 +526,12 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
|
|||||||
Syslog('m', "Aka match level is %d", i);
|
Syslog('m', "Aka match level is %d", i);
|
||||||
|
|
||||||
if (i >= METRIC_NET) {
|
if (i >= METRIC_NET) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_DISC_BADADD",Area,ascfnode(t, 0x1f),"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You may not disconnect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f));
|
fprintf(tmp, "You may not disconnect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f));
|
||||||
Syslog('+', " %s may not disconnect from group %s", ascfnode(t, 0x1f), fgroup.Name);
|
Syslog('+', " %s may not disconnect from group %s", ascfnode(t, 0x1f), fgroup.Name);
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,8 +541,12 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
|
|||||||
Sys.receivefrom = FALSE;
|
Sys.receivefrom = FALSE;
|
||||||
|
|
||||||
if (!TicSystemConnected(Sys)) {
|
if (!TicSystemConnected(Sys)) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NC",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You are not connected to %s\n", Area);
|
fprintf(tmp, "You are not connected to %s\n", Area);
|
||||||
Syslog('+', " %s is not connected to %s", ascfnode(t, 0x1f), Area);
|
Syslog('+', " %s is not connected to %s", ascfnode(t, 0x1f), Area);
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,16 +557,23 @@ void F_Disconnect(faddr *t, char *Area, FILE *tmp)
|
|||||||
*/
|
*/
|
||||||
f_list = TRUE;
|
f_list = TRUE;
|
||||||
Syslog('+', "Disconnected file area %s", Area);
|
Syslog('+', "Disconnected file area %s", Area);
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","OK_DISC",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Disconnected from area %s\n", Area);
|
fprintf(tmp, "Disconnected from area %s\n", Area);
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_DISC_NOTAVAIL",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You may not disconnect area %s, area is mandatory\n", Area);
|
fprintf(tmp, "You may not disconnect area %s, area is mandatory\n", Area);
|
||||||
Syslog('+', "Didn't disconnect %s from mandatory file area %s", ascfnode(t, 0x1f), Area);
|
Syslog('+', "Didn't disconnect %s from mandatory file area %s", ascfnode(t, 0x1f), Area);
|
||||||
|
MacroClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void F_Connect(faddr *, char *, FILE *);
|
void F_Connect(faddr *, char *, FILE *);
|
||||||
void F_Connect(faddr *t, char *Area, FILE *tmp)
|
void F_Connect(faddr *t, char *Area, FILE *tmp)
|
||||||
{
|
{
|
||||||
@ -628,6 +590,9 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|||||||
Area[i] = toupper(Area[i]);
|
Area[i] = toupper(Area[i]);
|
||||||
|
|
||||||
if (!SearchTic(Area)) {
|
if (!SearchTic(Area)) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTFOUND",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Area %s not found\n", Area);
|
fprintf(tmp, "Area %s not found\n", Area);
|
||||||
Syslog('m', " Area not found");
|
Syslog('m', " Area not found");
|
||||||
/* SHOULD CHECK FOR AREAS FILE AND ASK UPLINK
|
/* SHOULD CHECK FOR AREAS FILE AND ASK UPLINK
|
||||||
@ -637,6 +602,7 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|||||||
RESTORE NODERECORD (IS GONE!)
|
RESTORE NODERECORD (IS GONE!)
|
||||||
FALLTHRU TO CONNECT DOWNLINK
|
FALLTHRU TO CONNECT DOWNLINK
|
||||||
*/
|
*/
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,8 +615,12 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Group == NULL) {
|
if (Group == NULL) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, "Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTGROUP",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You may not connect to area %s\n", Area);
|
fprintf(tmp, "You may not connect to area %s\n", Area);
|
||||||
Syslog('+', " Group %s not available for %s", fgroup.Name, ascfnode(t, 0x1f));
|
Syslog('+', " Group %s not available for %s", fgroup.Name, ascfnode(t, 0x1f));
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -659,8 +629,12 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|||||||
Syslog('m', "Aka match level is %d", i);
|
Syslog('m', "Aka match level is %d", i);
|
||||||
|
|
||||||
if (i >= METRIC_NET) {
|
if (i >= METRIC_NET) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_CONN_BADADD",Area,ascfnode(t, 0x1f),"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You may not connect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f));
|
fprintf(tmp, "You may not connect area %s with nodenumber %s\n", Area, ascfnode(t, 0x1f));
|
||||||
Syslog('+', " Node %s may not connect to group %s", ascfnode(t, 0x1f), fgroup.Name);
|
Syslog('+', " Node %s may not connect to group %s", ascfnode(t, 0x1f), fgroup.Name);
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,8 +643,12 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|||||||
Sys.sendto = TRUE;
|
Sys.sendto = TRUE;
|
||||||
|
|
||||||
if (TicSystemConnected(Sys)) {
|
if (TicSystemConnected(Sys)) {
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_CONN_ALREADY",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "You are already connected to %s\n", Area);
|
fprintf(tmp, "You are already connected to %s\n", Area);
|
||||||
Syslog('+', " %s is already connected to %s", ascfnode(t, 0x1f), Area);
|
Syslog('+', " %s is already connected to %s", ascfnode(t, 0x1f), Area);
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -681,12 +659,19 @@ void F_Connect(faddr *t, char *Area, FILE *tmp)
|
|||||||
*/
|
*/
|
||||||
f_list = TRUE;
|
f_list = TRUE;
|
||||||
Syslog('+', "Connected to file area %s", Area);
|
Syslog('+', "Connected to file area %s", Area);
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","OK_CONN",Area,aka2str(tic.Aka),"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Connected to area %s using aka %s\n", Area, aka2str(tic.Aka));
|
fprintf(tmp, "Connected to area %s using aka %s\n", Area, aka2str(tic.Aka));
|
||||||
|
MacroClear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","ERR_CONN_NOTAVAIL",Area,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Not connected to %s, internal error, sysop is notified\n", Area);
|
fprintf(tmp, "Not connected to %s, internal error, sysop is notified\n", Area);
|
||||||
WriteError("Can't connect node %s to file area %s", ascfnode(t, 0x1f), Area);
|
WriteError("Can't connect node %s to file area %s", ascfnode(t, 0x1f), Area);
|
||||||
|
MacroClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -769,7 +754,11 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
|
|||||||
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
||||||
fwrite(&Sys, sizeof(Sys), 1, fp);
|
fwrite(&Sys, sizeof(Sys), 1, fp);
|
||||||
Syslog('+', "FileMgr: Connected %s", tic.Name);
|
Syslog('+', "FileMgr: Connected %s", tic.Name);
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","OK_CONN",tic.Name,aka2str(tic.Aka),"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Connected area %s using aka %s\n", tic.Name, aka2str(tic.Aka));
|
fprintf(tmp, "Connected area %s using aka %s\n", tic.Name, aka2str(tic.Aka));
|
||||||
|
MacroClear();
|
||||||
f_list = TRUE;
|
f_list = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -784,7 +773,11 @@ void F_All(faddr *t, int Connect, FILE *tmp, char *Grp)
|
|||||||
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
||||||
fwrite(&Sys, sizeof(Sys), 1, fp);
|
fwrite(&Sys, sizeof(Sys), 1, fp);
|
||||||
Syslog('+', "FileMgr: Disconnected %s", tic.Name);
|
Syslog('+', "FileMgr: Disconnected %s", tic.Name);
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","OK_DISC",tic.Name,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Disconnected area %s\n", tic.Name);
|
fprintf(tmp, "Disconnected area %s\n", tic.Name);
|
||||||
|
MacroClear();
|
||||||
f_list = TRUE;
|
f_list = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -850,8 +843,8 @@ void F_Pause(faddr *t, int Pause, FILE *tmp)
|
|||||||
Sys.pause = Pause;
|
Sys.pause = Pause;
|
||||||
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
fseek(fp, - sizeof(Sys), SEEK_CUR);
|
||||||
fwrite(&Sys, sizeof(Sys), 1, fp);
|
fwrite(&Sys, sizeof(Sys), 1, fp);
|
||||||
Syslog('+', "FileMgr: %s area %s", Pause?"Pause":"Resume", msgs.Tag);
|
Syslog('+', "FileMgr: %s area %s", Pause?"Pause":"Resume", tic.Name);
|
||||||
fprintf(tmp, "%s area %s\n", Pause?"Pause":"Resume", msgs.Tag);
|
fprintf(tmp, "%s area %s\n", Pause?"Pause":"Resume", tic.Name);
|
||||||
f_list = TRUE;
|
f_list = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -879,7 +872,11 @@ void F_Message(faddr *t, char *Buf, FILE *tmp)
|
|||||||
UpdateNode();
|
UpdateNode();
|
||||||
SearchNodeFaddr(t);
|
SearchNodeFaddr(t);
|
||||||
Syslog('+', "FileMgr: Message %s", GetBool(nodes.Message));
|
Syslog('+', "FileMgr: Message %s", GetBool(nodes.Message));
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "sdssss","OK_MESSAGE",nodes.Message,"","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "FileMgr Message file is %s\n", GetBool(nodes.Message));
|
fprintf(tmp, "FileMgr Message file is %s\n", GetBool(nodes.Message));
|
||||||
|
MacroClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -903,20 +900,29 @@ void F_Tick(faddr *t, char *Buf, FILE *tmp)
|
|||||||
SearchNodeFaddr(t);
|
SearchNodeFaddr(t);
|
||||||
Syslog('+', "FileMgr: Tick %s, Advanced %s", GetBool(nodes.Tic), GetBool(nodes.AdvTic));
|
Syslog('+', "FileMgr: Tick %s, Advanced %s", GetBool(nodes.Tic), GetBool(nodes.AdvTic));
|
||||||
if (nodes.Tic)
|
if (nodes.Tic)
|
||||||
if (nodes.AdvTic)
|
if (nodes.AdvTic){
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "sddsss","OK_TIC_ADV",nodes.Tic,nodes.AdvTic,"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Tick mode is advanced\n");
|
fprintf(tmp, "Tick mode is advanced\n");
|
||||||
else
|
}else{
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "sddsss","OK_TIC_NORM",nodes.Tic,nodes.AdvTic,"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Tick mode is normal\n");
|
fprintf(tmp, "Tick mode is normal\n");
|
||||||
else
|
}else{
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "sddsss","OK_TIC_OFF",nodes.Tic,nodes.AdvTic,"","","");
|
||||||
|
if (!MsgResult("filemgr.responses",tmp))
|
||||||
fprintf(tmp, "Tick mode is off\n");
|
fprintf(tmp, "Tick mode is off\n");
|
||||||
}
|
}
|
||||||
|
MacroClear();
|
||||||
|
}
|
||||||
|
|
||||||
int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int flags, FILE *fp)
|
int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int flags, FILE *fp)
|
||||||
{
|
{
|
||||||
int i, rc = 0, spaces;
|
int i, rc = 0, spaces;
|
||||||
char *Buf;
|
char *Buf, *subject;
|
||||||
FILE *tmp, *np;
|
FILE *tmp, *np;
|
||||||
|
|
||||||
f_help = f_stat = f_unlnk = f_list = f_query = FALSE;
|
f_help = f_stat = f_unlnk = f_list = f_query = FALSE;
|
||||||
@ -996,14 +1002,18 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
|
|||||||
F_Group(f, Buf, FALSE, tmp);
|
F_Group(f, Buf, FALSE, tmp);
|
||||||
else if (!strncasecmp(Buf, "%pause", 6))
|
else if (!strncasecmp(Buf, "%pause", 6))
|
||||||
F_Pause(f, TRUE, tmp);
|
F_Pause(f, TRUE, tmp);
|
||||||
|
else if (!strncasecmp(Buf, "%passive", 8))
|
||||||
|
F_Pause(f, TRUE, tmp);
|
||||||
else if (!strncasecmp(Buf, "%resume", 7))
|
else if (!strncasecmp(Buf, "%resume", 7))
|
||||||
F_Pause(f, FALSE, tmp);
|
F_Pause(f, FALSE, tmp);
|
||||||
|
else if (!strncasecmp(Buf, "%active", 7))
|
||||||
|
F_Pause(f, FALSE, tmp);
|
||||||
else if (!strncasecmp(Buf, "%password", 9))
|
else if (!strncasecmp(Buf, "%password", 9))
|
||||||
MgrPasswd(f, Buf, tmp, 9);
|
MgrPasswd(f, Buf, tmp, 9, 1);
|
||||||
else if (!strncasecmp(Buf, "%pwd", 4))
|
else if (!strncasecmp(Buf, "%pwd", 4))
|
||||||
MgrPasswd(f, Buf, tmp, 4);
|
MgrPasswd(f, Buf, tmp, 4, 1);
|
||||||
else if (!strncasecmp(Buf, "%notify", 7))
|
else if (!strncasecmp(Buf, "%notify", 7))
|
||||||
MgrNotify(f, Buf, tmp);
|
MgrNotify(f, Buf, tmp, 1);
|
||||||
else if (!strncasecmp(Buf, "%message", 8))
|
else if (!strncasecmp(Buf, "%message", 8))
|
||||||
F_Message(f, Buf, tmp);
|
F_Message(f, Buf, tmp);
|
||||||
else if (!strncasecmp(Buf, "%tick", 5))
|
else if (!strncasecmp(Buf, "%tick", 5))
|
||||||
@ -1016,25 +1026,37 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ftell(tmp)) {
|
if (ftell(tmp)) {
|
||||||
if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", (char *)"Your FileMgr request", replyid)) != NULL) {
|
subject=calloc(256,sizeof(char));
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,"Filemgr");
|
||||||
|
MacroVars("RABCDE", "ssssss","","","","","","");
|
||||||
|
sprintf(subject,"Your FileMgr request");
|
||||||
|
GetRpSubject("filemgr.responses",subject);
|
||||||
|
if ((np = SendMgrMail(f, CFG.ct_KeepMgr, FALSE, (char *)"Filemgr", subject, replyid)) != NULL) {
|
||||||
|
MacroVars("RABCDE", "ssssss","WELLCOME","","","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",np)){
|
||||||
fprintf(np, " Dear %s\r\r", nodes.Sysop);
|
fprintf(np, " Dear %s\r\r", nodes.Sysop);
|
||||||
fprintf(np, "Here is the result of your FileMgr request:\r\r");
|
fprintf(np, "Here is the result of your FileMgr request:\r\r");
|
||||||
|
}
|
||||||
fseek(tmp, 0, SEEK_SET);
|
fseek(tmp, 0, SEEK_SET);
|
||||||
|
|
||||||
while ((fgets(Buf, 2048, tmp)) != NULL) {
|
while ((fgets(Buf, 2048, tmp)) != NULL) {
|
||||||
|
while ((Buf[strlen(Buf) - 1]=='\n') || (Buf[strlen(Buf) - 1]=='\r')) {
|
||||||
Buf[strlen(Buf) - 1] = '\0';
|
Buf[strlen(Buf) - 1] = '\0';
|
||||||
|
}
|
||||||
fprintf(np, "%s\r", Buf);
|
fprintf(np, "%s\r", Buf);
|
||||||
Syslog('m', "Rep: %s", Buf);
|
Syslog('m', "Rep: %s", Buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MacroVars("RABCDE", "ssssss","GOODBYE","","","","","");
|
||||||
|
if (!MsgResult("filemgr.responses",np))
|
||||||
fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name);
|
fprintf(np, "\rWith regards, %s\r\r", CFG.sysop_name);
|
||||||
fprintf(np, "%s\r", TearLine());
|
fprintf(np, "%s\r", TearLine());
|
||||||
CloseMail(np, t);
|
CloseMail(np, t);
|
||||||
} else
|
} else
|
||||||
WriteError("Can't create netmail");
|
WriteError("Can't create netmail");
|
||||||
|
free(subject);
|
||||||
}
|
}
|
||||||
|
MacroClear();
|
||||||
free(Buf);
|
free(Buf);
|
||||||
fclose(tmp);
|
fclose(tmp);
|
||||||
|
|
||||||
@ -1056,4 +1078,3 @@ int FileMgr(faddr *f, faddr *t, char *replyid, char *subj, time_t mdate, int fla
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
148
mbfido/mgrutil.c
148
mbfido/mgrutil.c
@ -35,13 +35,13 @@
|
|||||||
#include "../lib/common.h"
|
#include "../lib/common.h"
|
||||||
#include "../lib/clcomm.h"
|
#include "../lib/clcomm.h"
|
||||||
#include "../lib/dbnode.h"
|
#include "../lib/dbnode.h"
|
||||||
|
#include "../lib/diesel.h"
|
||||||
#include "sendmail.h"
|
#include "sendmail.h"
|
||||||
#include "rollover.h"
|
#include "rollover.h"
|
||||||
#include "addpkt.h"
|
#include "addpkt.h"
|
||||||
#include "mgrutil.h"
|
#include "mgrutil.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
extern int net_out;
|
extern int net_out;
|
||||||
|
|
||||||
|
|
||||||
@ -51,27 +51,38 @@ extern int net_out;
|
|||||||
*/
|
*/
|
||||||
void WriteMailGroups(FILE *fp, faddr *f)
|
void WriteMailGroups(FILE *fp, faddr *f)
|
||||||
{
|
{
|
||||||
int Count = 0, First = TRUE;
|
int Count = 0, First = TRUE, res;
|
||||||
char *Group, *temp;
|
char *Group, *temp, *line;
|
||||||
FILE *gp;
|
FILE *gp,*fi;
|
||||||
faddr *g;
|
faddr *g;
|
||||||
|
fpos_t fileptr;
|
||||||
|
|
||||||
temp = calloc(128, sizeof(char));
|
temp = calloc(128, sizeof(char));
|
||||||
fprintf(fp, "Dear %s\r\r", nodes.Sysop);
|
line = calloc(256, sizeof(char));
|
||||||
sprintf(temp, "%s/etc/mgroups.data", getenv("MBSE_ROOT"));
|
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));
|
||||||
|
}
|
||||||
|
fgetpos(fi,&fileptr);
|
||||||
|
}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));
|
fprintf(fp, "The following is a list of mail groups at %s\r\r", ascfnode(f, 0x1f));
|
||||||
|
}
|
||||||
if ((gp = fopen(temp, "r")) == NULL) {
|
if ((gp = fopen(temp, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", temp);
|
WriteError("$Can't open %s", temp);
|
||||||
|
free(temp);
|
||||||
|
free(line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
|
fread(&mgrouphdr, sizeof(mgrouphdr), 1, gp);
|
||||||
|
|
||||||
|
if (fi == NULL){
|
||||||
// 123456789012 1234567890123456789012345678901234567890123456789012345
|
|
||||||
fprintf(fp, "Group Description\r");
|
fprintf(fp, "Group Description\r");
|
||||||
fprintf(fp, "--------------------------------------------------------------------\r");
|
fprintf(fp, "--------------------------------------------------------------------\r");
|
||||||
|
}
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
Group = GetNodeMailGrp(First);
|
Group = GetNodeMailGrp(First);
|
||||||
if (Group == NULL)
|
if (Group == NULL)
|
||||||
@ -84,17 +95,32 @@ void WriteMailGroups(FILE *fp, faddr *f)
|
|||||||
if ((!strcmp(mgroup.Name, Group)) &&
|
if ((!strcmp(mgroup.Name, Group)) &&
|
||||||
(g->zone == f->zone) && (g->net == f->net) &&
|
(g->zone == f->zone) && (g->net == f->net) &&
|
||||||
(g->node == f->node) && (g->point == f->point)) {
|
(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));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
fprintf(fp, "%-12s %s\r", mgroup.Name, mgroup.Comment);
|
fprintf(fp, "%-12s %s\r", mgroup.Name, mgroup.Comment);
|
||||||
|
}
|
||||||
Count++;
|
Count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fi != NULL){
|
||||||
|
MacroVars("b", "d", Count );
|
||||||
|
while ( fgets(line, 254, fi) != NULL ){
|
||||||
|
fprintf( fp, "%s", ParseMacro(line,&res));
|
||||||
|
}
|
||||||
|
fclose(fi);
|
||||||
|
}else{
|
||||||
fprintf(fp, "--------------------------------------------------------------------\r");
|
fprintf(fp, "--------------------------------------------------------------------\r");
|
||||||
fprintf(fp, "%d group(s)\r\r\r", Count);
|
fprintf(fp, "%d group(s)\r\r\r", Count);
|
||||||
|
}
|
||||||
fclose(gp);
|
fclose(gp);
|
||||||
|
free(line);
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,27 +131,38 @@ void WriteMailGroups(FILE *fp, faddr *f)
|
|||||||
*/
|
*/
|
||||||
void WriteFileGroups(FILE *fp, faddr *f)
|
void WriteFileGroups(FILE *fp, faddr *f)
|
||||||
{
|
{
|
||||||
int Count = 0, First = TRUE;
|
int Count = 0, First = TRUE, res;
|
||||||
char *Group, *temp;
|
char *Group, *temp, *line;
|
||||||
FILE *gp;
|
FILE *gp, *fi;
|
||||||
faddr *g;
|
faddr *g;
|
||||||
|
fpos_t fileptr;
|
||||||
|
|
||||||
temp = calloc(128, sizeof(char));
|
temp = calloc(128, sizeof(char));
|
||||||
fprintf(fp, "Dear %s\r\r", nodes.Sysop);
|
line = calloc(256, sizeof(char));
|
||||||
sprintf(temp, "%s/etc/fgroups.data", getenv("MBSE_ROOT"));
|
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));
|
||||||
|
}
|
||||||
|
fgetpos(fi,&fileptr);
|
||||||
|
}else{
|
||||||
|
fprintf(fp, "Dear %s\r\r", nodes.Sysop);
|
||||||
fprintf(fp, "The following is a list of file groups at %s\r\r", ascfnode(f, 0x1f));
|
fprintf(fp, "The following is a list of file groups at %s\r\r", ascfnode(f, 0x1f));
|
||||||
|
}
|
||||||
if ((gp = fopen(temp, "r")) == NULL) {
|
if ((gp = fopen(temp, "r")) == NULL) {
|
||||||
WriteError("$Can't open %s", temp);
|
WriteError("$Can't open %s", temp);
|
||||||
|
free(temp);
|
||||||
|
free(line);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
fread(&fgrouphdr, sizeof(fgrouphdr), 1, gp);
|
||||||
|
|
||||||
|
if (fi == NULL){
|
||||||
// 123456789012 1234567890123456789012345678901234567890123456789012345
|
|
||||||
fprintf(fp, "Group Description\r");
|
fprintf(fp, "Group Description\r");
|
||||||
fprintf(fp, "--------------------------------------------------------------------\r");
|
fprintf(fp, "--------------------------------------------------------------------\r");
|
||||||
|
}
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
Group = GetNodeFileGrp(First);
|
Group = GetNodeFileGrp(First);
|
||||||
if (Group == NULL)
|
if (Group == NULL)
|
||||||
@ -138,17 +175,32 @@ void WriteFileGroups(FILE *fp, faddr *f)
|
|||||||
if ((!strcmp(fgroup.Name, Group)) &&
|
if ((!strcmp(fgroup.Name, Group)) &&
|
||||||
(g->zone == f->zone) && (g->net == f->net) &&
|
(g->zone == f->zone) && (g->net == f->net) &&
|
||||||
(g->node == f->node) && (g->point == f->point)) {
|
(g->node == f->node) && (g->point == f->point)) {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
fprintf(fp, "%-12s %s\r", fgroup.Name, fgroup.Comment);
|
fprintf(fp, "%-12s %s\r", fgroup.Name, fgroup.Comment);
|
||||||
|
}
|
||||||
Count++;
|
Count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fi != NULL){
|
||||||
|
MacroVars("b", "d", Count );
|
||||||
|
while ( fgets(line, 254, fi) != NULL ){
|
||||||
|
fprintf( fp, "%s", ParseMacro(line,&res));
|
||||||
|
}
|
||||||
|
fclose(fi);
|
||||||
|
}else{
|
||||||
fprintf(fp, "--------------------------------------------------------------------\r");
|
fprintf(fp, "--------------------------------------------------------------------\r");
|
||||||
fprintf(fp, "%d group(s)\r\r\r", Count);
|
fprintf(fp, "%d group(s)\r\r\r", Count);
|
||||||
|
}
|
||||||
fclose(gp);
|
fclose(gp);
|
||||||
|
free(line);
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,12 +244,14 @@ void CleanBuf(char *Buf)
|
|||||||
/*
|
/*
|
||||||
* Change AreaMgr and FileMgr password for a node
|
* Change AreaMgr and FileMgr password for a node
|
||||||
*/
|
*/
|
||||||
void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len)
|
void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len, int mgr)
|
||||||
{
|
{
|
||||||
ShiftBuf(Buf, Len);
|
ShiftBuf(Buf, Len);
|
||||||
CleanBuf(Buf);
|
CleanBuf(Buf);
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop, mgr?(char *)"Filemgr":(char *)"Areamgr");
|
||||||
if ((strlen(Buf) < 3) || (strlen(Buf) > 15)) {
|
if ((strlen(Buf) < 3) || (strlen(Buf) > 15)) {
|
||||||
|
MacroVars("RABCDE", "ssssss",(char *)"ERR_PASS_LEN",(char *)"",(char *)"",(char *)"",(char *)"",(char *)"");
|
||||||
|
if (!MsgResult(mgr?"filemgr.responses":"areamgr.responses",tmp))
|
||||||
fprintf(tmp, "A new password must be between 3 and 15 characters in length\n");
|
fprintf(tmp, "A new password must be between 3 and 15 characters in length\n");
|
||||||
Syslog('+', "XxxxMgr: Password length %d, not changed", strlen(Buf));
|
Syslog('+', "XxxxMgr: Password length %d, not changed", strlen(Buf));
|
||||||
return;
|
return;
|
||||||
@ -205,8 +259,11 @@ void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len)
|
|||||||
|
|
||||||
memset(&nodes.Apasswd, 0, sizeof(nodes.Apasswd));
|
memset(&nodes.Apasswd, 0, sizeof(nodes.Apasswd));
|
||||||
strncpy(nodes.Apasswd, tu(Buf), 15);
|
strncpy(nodes.Apasswd, tu(Buf), 15);
|
||||||
|
MacroVars("RABCDE", "ssssss",(char *)"OK_PASS",nodes.Apasswd,(char *)"",(char *)"",(char *)"",(char *)"");
|
||||||
|
if (!MsgResult(mgr?"filemgr.responses":"areamgr.responses",tmp))
|
||||||
fprintf(tmp, "AreaMgr and FileMgr password is now \"%s\"\n", nodes.Apasswd);
|
fprintf(tmp, "AreaMgr and FileMgr password is now \"%s\"\n", nodes.Apasswd);
|
||||||
Syslog('+', "XxxxMgr: Password \"%s\" for node %s", nodes.Apasswd, ascfnode(t, 0x1f));
|
Syslog('+', "XxxxMgr: Password \"%s\" for node %s", nodes.Apasswd, ascfnode(t, 0x1f));
|
||||||
|
MacroClear();
|
||||||
UpdateNode();
|
UpdateNode();
|
||||||
SearchNodeFaddr(t);
|
SearchNodeFaddr(t);
|
||||||
}
|
}
|
||||||
@ -216,7 +273,7 @@ void MgrPasswd(faddr *t, char *Buf, FILE *tmp, int Len)
|
|||||||
/*
|
/*
|
||||||
* Change AreaMgr/FileMgr nodify flag for node
|
* Change AreaMgr/FileMgr nodify flag for node
|
||||||
*/
|
*/
|
||||||
void MgrNotify(faddr *t, char *Buf, FILE *tmp)
|
void MgrNotify(faddr *t, char *Buf, FILE *tmp, int mgr)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* First strip leading garbage
|
* First strip leading garbage
|
||||||
@ -234,7 +291,11 @@ void MgrNotify(faddr *t, char *Buf, FILE *tmp)
|
|||||||
UpdateNode();
|
UpdateNode();
|
||||||
SearchNodeFaddr(t);
|
SearchNodeFaddr(t);
|
||||||
Syslog('+', "XxxxMgr: Notify %s", GetBool(nodes.Notify));
|
Syslog('+', "XxxxMgr: Notify %s", GetBool(nodes.Notify));
|
||||||
|
MacroVars("SsP", "sss", CFG.sysop_name, nodes.Sysop,mgr?(char *)"Filemgr":(char *)"Areamgr");
|
||||||
|
MacroVars("RABCDE", "ssssss",(char *)"OK_PASS",nodes.Apasswd,(char *)"",(char *)"",(char *)"",(char *)"");
|
||||||
|
if (!MsgResult(mgr?"filemgr.responses":"areamgr.responses",tmp))
|
||||||
fprintf(tmp, "AreaMgr and FileMgr Notify is %s\n", GetBool(nodes.Notify));
|
fprintf(tmp, "AreaMgr and FileMgr Notify is %s\n", GetBool(nodes.Notify));
|
||||||
|
MacroClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -368,3 +429,42 @@ int UplinkRequest(faddr *t, int FileMgr, char *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GetRpSubject(const char *report, char* subject)
|
||||||
|
{
|
||||||
|
FILE *fi;
|
||||||
|
char *temp;
|
||||||
|
int res;
|
||||||
|
temp = calloc(256,sizeof(char));
|
||||||
|
if ((fi=OpenMacro(report, nodes.Language))!=NULL){
|
||||||
|
while ( fgets(temp, 254, fi) != NULL )
|
||||||
|
ParseMacro(temp,&res);
|
||||||
|
fclose(fi);
|
||||||
|
}
|
||||||
|
res=diesel("@(getvar,subject)",temp);
|
||||||
|
Syslog('d', "diesel: %d %s", res, temp);
|
||||||
|
if(res==0)
|
||||||
|
sprintf(subject,"%s",temp);
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MsgResult(const char * report, FILE *fo)
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
fclose(fi);
|
||||||
|
res=1;
|
||||||
|
}else{
|
||||||
|
res=0;
|
||||||
|
}
|
||||||
|
free(temp);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,13 +4,16 @@
|
|||||||
#define _MGRUTIL_H
|
#define _MGRUTIL_H
|
||||||
|
|
||||||
|
|
||||||
|
int MsgResult(const char *, FILE * );
|
||||||
|
void GetRpSubject(const char *, char*);
|
||||||
|
|
||||||
void WriteMailGroups(FILE *, faddr *);
|
void WriteMailGroups(FILE *, faddr *);
|
||||||
void WriteFileGroups(FILE *, faddr *);
|
void WriteFileGroups(FILE *, faddr *);
|
||||||
char *GetBool(int);
|
char *GetBool(int);
|
||||||
void CleanBuf(char *);
|
void CleanBuf(char *);
|
||||||
void ShiftBuf(char *, int);
|
void ShiftBuf(char *, int);
|
||||||
void MgrPasswd(faddr *, char *, FILE *, int);
|
void MgrPasswd(faddr *, char *, FILE *, int, int);
|
||||||
void MgrNotify(faddr *, char *, FILE *);
|
void MgrNotify(faddr *, char *, FILE *, int);
|
||||||
int UplinkRequest(faddr *, int, char *);
|
int UplinkRequest(faddr *, int, char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user