1N/A * Copyright (c) 1998-2001, 2003, 2006, 2007 Sendmail, Inc. and its suppliers. 1N/A * All rights reserved. 1N/A * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 1N/A * Copyright (c) 1988, 1993 1N/A * The Regents of the University of California. All rights reserved. 1N/A * By using this file, you agree to the terms and conditions set 1N/A * forth in the LICENSE file which can be found at the top level of 1N/A * the sendmail distribution. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A#
endif /* MAXMACROID != (BITMAPBITS - 1) */ 1N/A** Codes for long named macros. 1N/A** See also macname(): 1N/A * if not ASCII printable, look up the name * 1N/A if (n <= 0x20 || n > 0x7f) 1N/A** First use 1 to NEXTMACROID_L, then use NEXTMACROID_H to MAXMACROID. 1N/A/* table for next id in non-printable ASCII range: disallow some value */ 1N/A#
else /* _FFR_MORE_MACROS */ 1N/A#
endif /* _FFR_MORE_MACROS */ 1N/A** INITMACROS -- initialize the macro system 1N/A** This just involves defining some macros that are actually 1N/A** used internally as metasymbols to be themselves. 1N/A** initializes several macros to be themselves. 1N/A /* LHS pattern matching characters */ 1N/A /* these are RHS metasymbols */ 1N/A /* the conditional operations */ 1N/A /* the hostname lookup characters */ 1N/A /* miscellaneous control characters */ 1N/A for (c =
'0'; c <=
'9'; c++)
1N/A /* set defaults for some macros sendmail will use later */ 1N/A /* set up external names for some internal macros */ 1N/A /*XXX should probably add equivalents for all short macros here XXX*/ 1N/A** After expansion, the expansion will be in external form (that is, 1N/A** there will be no sendmail metacharacters and METAQUOTEs will have 1N/A** been stripped out). 1N/A** s -- the string to expand. 1N/A** buf -- the place to put the expansion. 1N/A** bufsize -- the size of the buffer. 1N/A** explevel -- the depth of expansion (doexpand only) 1N/A** e -- envelope in which to work. 1N/A bool skipping;
/* set if conditionally skipping output */ 1N/A ** Check for non-ordinary (special?) character. 1N/A ** 'q' will be the interpolated quantity. 1N/A break;
/* XXX: error */ 1N/A break;
/* XXX: error */ 1N/A /* next octet completely quoted */ 1N/A ** Interpolate q or output one character 1N/A /* copy to end of q or max space remaining in buf */ 1N/A while ((c = *q++) !=
'\0' &&
1N/A /* check for any sendmail metacharacters */ 1N/A /* give quoted characters a free ride */ 1N/A /* recurse as appropriate */ 1N/A syserr(
"expand: recursion too deep (%d max)",
1N/A /* copy results out */ 1N/A /* leave in internal form */ 1N/A** MACDEFINE -- bind a macro name to a value 1N/A** Set a macro to a value, with fancy storage management. 1N/A** macdefine will make a copy of the value, if required, 1N/A** and will ensure that the storage for the previous value 1N/A** mac -- Macro table. 1N/A** vclass -- storage class of 'value', ignored if value==NULL. 1N/A** A_HEAP means that the value was allocated by 1N/A** malloc, and that macdefine owns the storage. 1N/A** A_TEMP means that value points to temporary storage, 1N/A** and thus macdefine needs to make a copy. 1N/A** A_PERM means that value points to storage that 1N/A** will remain allocated and unchanged for 1N/A** at least the lifetime of mac. Use A_PERM if: 1N/A** -- value points to a string literal, 1N/A** -- value was allocated from mac->mac_rpool 1N/A** or (in the case of an envelope macro) 1N/A** -- in the case of an envelope macro, 1N/A** value is a string member of the envelope 1N/A** such as e->e_sender. 1N/A** id -- Macro id. This is a single character macro name 1N/A** such as 'g', or a value returned by macid(). 1N/A** value -- Macro value: either NULL, or a string. 1N/A#
else /* SM_HEAP_CHECK */ 1N/A#
endif /* SM_HEAP_CHECK */ 1N/A#
endif /* SM_HEAP_CHECK */ 1N/A#
else /* SM_HEAP_CHECK */ 1N/A#
endif /* SM_HEAP_CHECK */ 1N/A#
endif /* _FFR_RESET_MACRO_GLOBALS */ 1N/A** MACSET -- set a named macro to a value (low level) 1N/A** No fancy storage management; the caller takes full responsibility. 1N/A** Often used with macget; see also macdefine. 1N/A** mac -- Macro table. 1N/A** i -- Macro name, specified as an integer offset. 1N/A** value -- Macro value: either NULL, or a string. 1N/A** MACVALUE -- return uninterpreted value of a macro. 1N/A** Does fancy path searching. 1N/A** The low level counterpart is macget. 1N/A** n -- the name of the macro. 1N/A** e -- envelope in which to start looking for the macro. 1N/A** MACNAME -- return the name of a macro given its internal id 1N/A** n -- the id of the macro 1N/A n = (
int)(
unsigned char)n;
1N/A return "***OUT OF RANGE MACRO***";
1N/A /* if not ASCII printable, look up the name */ 1N/A if (n <=
0x20 || n >
0x7f)
1N/A return "***UNDEFINED MACRO***";
1N/A /* if in the ASCII graphic range, just return the id directly */ 1N/A** MACID_PARSE -- return id of macro identified by its name 1N/A** p -- pointer to name string -- either a single 1N/A** character or {name}. 1N/A** ep -- filled in with the pointer to the byte 1N/A** 0 -- An error was detected. 1N/A** 1..MAXMACROID -- The internal id code for this macro. 1N/A** If this is a new macro name, a new id is allocated. 1N/A** On error, syserr is called. 1N/A if (*p ==
'\0' || (p[0] ==
'{' && p[
1] ==
'}'))
1N/A /* the macro is its own code */ 1N/A while (*++p !=
'\0' && *p !=
'}' &&
bp < &
mbuf[
sizeof(
mbuf) -
1])
1N/A** WORDINCLASS -- tell if a word is in a specific class 1N/A** str -- the name of the word to look up. 1N/A** cl -- the class name. 1N/A** true if str can be found in cl.