static char SccsId
[] = "@(#)readcf.c 3.8 %G%";
** READCF -- read control file.
** This routine reads the control file and builds the internal
** cfname -- control file name.
** Builds several internal tables.
struct rewrite
*RewriteRules
[10];
struct rewrite
*rwp
= NULL
;
extern char **copyplist();
syserr("cannot open %s", cfname
);
while (fgets(buf
, sizeof buf
, cf
) != NULL
)
case 'R': /* rewriting rule */
for (p
= &buf
[1]; *p
!= '\0' && *p
!= '\t'; p
++)
syserr("invalid rewrite line \"%s\"", buf
);
RewriteRules
[ruleset
] = rwp
=
(struct rewrite
*) xalloc(sizeof *rwp
);
rwp
->r_next
= (struct rewrite
*) xalloc(sizeof *rwp
);
rwp
->r_lhs
= prescan(&buf
[1], '\t');
rwp
->r_lhs
= copyplist(rwp
->r_lhs
, TRUE
);
rwp
->r_rhs
= prescan(p
, '\t');
rwp
->r_rhs
= copyplist(rwp
->r_rhs
, TRUE
);
case 'S': /* select rewriting set */
case 'D': /* macro definition */
define(buf
[1], newstr(&buf
[2]));
case 'H': /* required header line */
(void) chompheader(&buf
[1], TRUE
);
case 'C': /* word class */
/* scan the list of words and set class 'i' for all */
for (p
= &buf
[2]; *p
!= '\0'; )
while (*p
!= '\0' && isspace(*p
))
while (*p
!= '\0' && !isspace(*p
))
s
= stab(wd
, ST_CLASS
, ST_ENTER
);
s
->s_class
|= 1 << class;
case 'M': /* define mailer */
syserr("unknown control line \"%s\"", buf
);
** MAKEMAILER -- define a new mailer.
** line -- description of mailer. This is in tokens
** separated by white space. The fields are:
** * the name of the mailer, as refered to
** in the rewriting rules.
** * the pathname of the program to fork to
** * the options needed by this program.
** * the macro string needed to translate
** a local "from" name to one that can be
** returned to this machine.
** * the argument vector (a series of parameters).
** enters the mailer into the mailer table.
while (*p != '\0' && isspace(*p)) \
while (*p != '\0' && !isspace(*p)) \
register struct mailer
*m
;
if (NextMailer
>= MAXMAILERS
)
syserr("Too many mailers defined");
/* collect initial information */
syserr("invalid M line in configuration file");
m
= (struct mailer
*) xalloc(sizeof *m
);
m
->m_name
= newstr(mname
);
m
->m_mailer
= newstr(mpath
);
m
->m_from
= newstr(mfrom
);
m
->m_badstat
= EX_UNAVAILABLE
;
Mailer
[NextMailer
++] = m
;
/* collect the argument vector */
for (i
= 0; i
< MAXPV
- 1 && *p
!= '\0'; i
++)
m
->m_argv
= (char **) xalloc(sizeof margv
[0] * i
);
bmove((char *) margv
, (char *) m
->m_argv
, sizeof margv
[0] * i
);
** PRINTRULES -- print rewrite rules (for debugging)
register struct rewrite
*rwp
;
for (ruleset
= 0; ruleset
< 10; ruleset
++)
if (RewriteRules
[ruleset
] == NULL
)
printf("\n----Rule Set %d:\n", ruleset
);
for (rwp
= RewriteRules
[ruleset
]; rwp
!= NULL
; rwp
= rwp
->r_next
)
for (av
= rwp
->r_lhs
; *av
!= NULL
; av
++)
for (av
= rwp
->r_rhs
; *av
!= NULL
; av
++)
** CRACKOPTS -- crack mailer options
** These options modify the functioning of the mailer
** from the configuration table.
** p -- pointer to vector of options.
** option list in binary.
char opt_name
; /* external name of option */
int opt_value
; /* internal name of option */
struct optlist OptList
[] =
register struct optlist
*o
;
for (o
= OptList
; o
->opt_name
!= '\0' && o
->opt_name
!= *p
; o
++)
syserr("bad mailer option %c", *p
);