static char SccsId
[] = "@(#)macro.c 3.2 %G%";
** EXPAND -- macro expand a string using $x escapes.
** s -- the string to expand.
** buf -- the place to put the expansion.
** buflim -- the buffer limit, i.e., the address
** of the last usable position in buf.
printf("expand(%s)\n", s
);
for (bp
= buf
; *s
!= '\0'; s
++)
/* q will be the interpolated quantity */
case '?': /* see if var set */
skipping
= Macro
[c
] == NULL
;
if (q
== NULL
&& c
!= '$')
** Interpolate q or output one character
bp
= expand(q
, bp
, buflim
);
else if (bp
< buflim
- 1)
printf("expand ==> '%s'\n", buf
);
** DEFINE -- define a macro.
** this would be better done using a #define macro.
** There is one macro for each ASCII character,
** although they are not all used. The currently
** $a date in arpa format
** $d date in ctime format
** $g translated from address
** $l UNIX-style from line+
** $n name of sendmail ("MAILER-DAEMON" on local
** $o delimiters ("operators") for address tokens+
** $p my process id in decimal
** $t the current time in seconds since 1/1/1970
** $v version number of sendmail
** $x signature (full name) of from person
** $z home directory of to person
** Macros marked with + must be defined in the
** configuration file and are used internally, but
** There are also some macros that can be used
** arbitrarily to make the configuration file
** cleaner. In general all upper-case letters
printf("define(%c as %s)\n", n
, v
);