I think I have come up with a solution to the macro problem
that meets the following criteria:

* It is easy for people to use, even if they don't have time to RTFM. 
  hence, backslashes will remove the special meta-significance of {

* It is possible to avoid backslashitis by allowing a special sequence
  ("{^") which tells the parser "treat all { as literal { characters until
  you see a ^} sequence".

* It allows a number of raw { characters without needing to resort to either
  of the above tricks.  It does this by only allowing [A-Za-z\xc0-\xfd] as
  the first character of the macro sequence (the reason for allowing high
  bit characters between \xc0 and \xfd is because this part of the parser is 
  not UTF-8 aware, and these high bit characters signify the beginning
  of a UTF-8 sequence).  { followed by anything else is rendered as a 
  literal {

I have a state machine design that meets all of the following criteria:

State	Input		  Action	  New State
1	\		  none		  2
1	{		  none		  3
1	anything else	  add		  1
2	{		  add		  1
2	anything else	  add \ then add  1
3	^		  none		  4
3	[A-Za-z\xc0-\xfd] new macro char  6
3	anything else	  add { then add  1
4	^		  none		  5
4	anything else	  add		  4
5	}		  none		  1
5	anything else	  add ^ then add  4
6	}		  process macro   1
6       anything else     add macro char  6

Description of the actions:

add: Add input character to output stream
add \: Add \ character to output stream
add {: Add { character to output stream
add ^: Add ^ character to output stream
add macro char: Add input character to macro name
new macro char: Create new character as first char of macro name
none: Make no change to output stream
process macro: Do macro substitution (which will do nothing for now but
               return syntax error that macro aren't supported yet)

Some other notes:

A macro is only allowed to have 40 non-hi-bit characters in it; anything
longer is assumed to be the user forgetting to add a } at the end of the
macro name.  An unlimited number of hi-bit characters are allowed because
UTF-8 sequences can become very long.

The state machine for processing TXT and RAW records will be modified to 
allow { characters to be in unquoted text, so as to minimize user confusion
(otherwise, the user has to remember the irrational rule to not backslash 
anything in quetes except the {, which can not be backslashed outside
of quotes.  Silly rule, so I'll make it so { can be backslashed either 
inside or outside of quotes, allowing the user to simply remember
"all backslash sequences need to be outside of quotes").

I will not actually implement macro processing for the 1.2/2.0 release
of MaraDNS; I will only put the hooks in the code to allow future csv2 
files to have macro support.

- Sam

